lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d405db9dd4ff587093539a602c45a2aeb85db90c.camel@perches.com>
Date:   Sun, 07 Nov 2021 20:02:59 -0800
From:   Joe Perches <joe@...ches.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     Wu Bo <wubo40@...wei.com>, viro@...iv.linux.org.uk,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        linfeilong@...wei.com
Subject: Re: [PATCH] fs: direct-io: use DIV_ROUND_UP helper macro for
 calculations

On Mon, 2021-11-08 at 03:52 +0000, Matthew Wilcox wrote:
> On Sun, Nov 07, 2021 at 07:17:07PM -0800, Joe Perches wrote:
> > If you are interested, there are definitely a few more opportunities
> > to use this DIV_ROUND_UP macro in the kernel:
> > 
> > $ git grep -P -n '\(\s*([\w\.\>\[\]\-]+)\s*\+\s*([\w\.\>\[\]\-]+)\s*-\s*1\s*\)\s*/\s*(?:\1|\2)\b'
> > arch/alpha/boot/tools/objstrip.c:260:	mem_size = ((mem_size + pad - 1) / pad) * pad;
> 
> Might want to exclude 'tools' ...
> 
> > tools/bpf/bpftool/gen.c:184:		align_off = (off + align - 1) / align * align;
> > tools/io_uring/io_uring-bench.c:140:	return (DEPTH + s->nr_files - 1) / s->nr_files;
> > tools/lib/bpf/linker.c:1115:	dst_align_sz = (dst->sec_sz + dst_align - 1) / dst_align * dst_align;
> > tools/lib/subcmd/help.c:119:	rows = (cmds->cnt + cols - 1) / cols;
> > tools/testing/selftests/bpf/prog_tests/core_reloc.c:804:	return (sz + page_size - 1) / page_size * page_size;
> > tools/testing/selftests/bpf/prog_tests/mmap.c:13:	return (sz + page_size - 1) / page_size * page_size;
> > tools/testing/selftests/net/forwarding/sch_red.sh:202:		local pkts=$(((diff + PKTSZ - 1) / PKTSZ))
> > tools/vm/page-types.c:943:			size, (size + page_size - 1) / page_size);
> 
> ... because most of these files won't have access to that macro.
> Definitely compile-test before sending a patch.

Always.

btw:

tools/include/linux/kernel.h:#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ