[PATCH] tracing: eliminate const char[] auto variables

2018-11-02 Thread Rasmus Villemoes
faulted variable used in tracing_mark_raw_write(). Finally, for the two runs of spaces, just use variables initialized with string literals; the linker (at least for x86) will reuse the tail of the longer for the shorter string. Signed-off-by: Rasmus Villemoes --- kernel/trace/ftrace.c | 2

[PATCH] bloat-o-meter: ignore __addressable_ symbols

2018-11-02 Thread Rasmus Villemoes
ction old new delta trace_default_header 663 642 -21 tracing_mark_raw_write 406 355 -51 tracing_mark_write 624 557 -67 Total: Before=63721, After=63582, chg -0.22% Signed-off-by: Rasmus Vill

[PATCH] perf: replace automatic const char[] variables by statics

2018-11-02 Thread Rasmus Villemoes
20 20 movabs $0x20202e646e756f66,%rax Make them all static so that the compiler just references objects in .rodata. Signed-off-by: Rasmus Villemoes --- tools/perf/builtin-c2c.c| 4 ++-- tools/perf/builtin-kmem.c | 4 ++-- tools/perf/builtin-report.c | 6 +++--- tools/perf/bu

Re: [RFC PATCH 0/7] runtime format string checking

2018-11-05 Thread Rasmus Villemoes
On 2018-11-01 23:57, Kees Cook wrote: >> Yes, gcc should be able to infer the constness of drv from the fact that >> it's never assigned to elsewhere in the function... I think I saw that >> on some gcc todo list at some point. > > If you find that bug, I'll add it to my gcc bug tracking list. :P

kstrdup_quotable_cmdline and gfp flags

2018-11-05 Thread Rasmus Villemoes
kstrdup_quotable_cmdline takes gfp flags and passes those on to kstrdup_quotable, but before that it has done a kmalloc(PAGE_SIZE) with a hard-coded GFP_KERNEL. There is one caller of kstrdup_quotable_cmdline which passes GFP_ATOMIC, and the commit introducing that (65a3c2748e) conveniently has thi

Re: [PATCH] slab.h: Avoid using & for logical and of booleans

2018-11-05 Thread Rasmus Villemoes
On 2018-11-05 22:48, Bart Van Assche wrote: > On Mon, 2018-11-05 at 13:13 -0800, Andrew Morton wrote: >> On Mon, 5 Nov 2018 12:40:00 -0800 Bart Van Assche >> wrote: >> >>> This patch suppresses the following sparse warning: >>> >>> ./include/linux/slab.h:332:43: warning: dubious: x & !y >>> >>>

Re: [PATCH 2/3] staging: greybus: loopback.c: do insertion in O(n) instead of O(n lg n)

2018-10-23 Thread Rasmus Villemoes
On 2018-10-11 01:03, Bryan O'Donoghue wrote: > On 05/10/2018 15:28, Rasmus Villemoes wrote: >> Signed-off-by: Rasmus Villemoes >> --- >> I have no idea if the performance matters (it probably doesn't). Feel >> free to ignore this and the followup cleanup. >

[PATCH v2] staging: greybus: loopback.c: remove unused lists

2018-10-24 Thread Rasmus Villemoes
orted. Reviewed-by: Bryan O'Donoghue Signed-off-by: Rasmus Villemoes --- Sending as a proper patch. Marked v2 since this replaces earlier 2/3 and 3/3 patches. Applies on top of b4fc4e8340784e30c5a59bf0791f9c3ce15e (staging: greybus: loopback.c: remove unused gb_loopback::lbid). drive

[PATCH] fs/file.c: make more use of cloexec bits not being cleared

2018-10-24 Thread Rasmus Villemoes
about the state of close_on_exec in the new bits when we expand the fdtable, we don't need to clear close_on_exec[i] in do_close_on_exec, and since we may have quite a few bits set in close_on_exec[i] without an actual open file, mask the set with open_fds[i]. Signed-off-by: Rasmus Villemoe

Re: [PATCH AUTOSEL 3.18 15/98] usb: musb: Fix a few off-by-one lengths

2018-10-26 Thread Rasmus Villemoes
On 2018-10-25 16:17, Sasha Levin wrote: > From: Rasmus Villemoes > > [ Upstream commit e87c3f80ad0490d26ffe04754b7d094463b40f30 ] > > !strncmp(buf, "force host", 9) is true if and only if buf starts with > "force hos". This was obviously not what was intend

[PATCH 3/3] tracing: simplify printf'ing in seq_print_sym

2018-10-26 Thread Rasmus Villemoes
the declaration of the str buffer inside the CONFIG_KALLSYMS guard, which in turn will make gcc inline the function for !CONFIG_KALLSYMS (it only has a single caller, but the huge stack frame seems to make gcc not inline it for CONFIG_KALLSYMS). Signed-off-by: Rasmus Villemoes --- kernel/trace/tra

[PATCH 1/3] tracing: merge seq_print_sym_short() and seq_print_sym_offset()

2018-10-26 Thread Rasmus Villemoes
These two functions are nearly identical, so we can avoid some code duplication by moving the conditional into a common implementation. Signed-off-by: Rasmus Villemoes --- kernel/trace/trace_output.c | 34 +++--- 1 file changed, 7 insertions(+), 27 deletions(-) diff

[PATCH 2/3] tracing: avoid -Wformat-nonliteral warning

2018-10-26 Thread Rasmus Villemoes
single caller which passes "%s" as fmt, so we might as well just use that directly. That also paves the way for further cleanups that will actually make that format string go away entirely. Signed-off-by: Rasmus Villemoes --- kernel/trace/trace_output.c | 9 - 1 file changed, 4

[PATCH] fs: proc: move linux_proc_banner to where it is used

2018-10-26 Thread Rasmus Villemoes
complain in the unlikely case one of the LINUX_* strings ended up containing a %. This also avoids compiling it in for !CONFIG_PROC_FS. Signed-off-by: Rasmus Villemoes --- fs/proc/version.c | 6 ++ include/linux/printk.h | 1 - init/version.c | 5 - 3 files changed, 6 insertions

[PATCH] x86: traps.c: use format string with panic() call

2018-10-26 Thread Rasmus Villemoes
with a string not containing format specifiers, but we might as well silence this warning using "%s" as format string. Signed-off-by: Rasmus Villemoes --- arch/x86/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kern

[RFC PATCH 3/7] kernel.h: implement fmtmatch() wrapper around fmtcheck()

2018-10-26 Thread Rasmus Villemoes
Some users may prefer to check a "user-supplied" string upfront and return EINVAL rather than using the the template as a fallback for printf'ing later. fmtmatch() is simply a shorthand for fmtcheck(a, b, c | FMTCHECK_SILENT) == a. Signed-off-by: Rasmus Villemoes --- include

[RFC PATCH 5/7] kernel/kthread.c: do runtime check of format string in kthread_create_on_cpu()

2018-10-26 Thread Rasmus Villemoes
One is supposed to pass in a format string containing (at most) one %u instance. Use fmtcheck() to enforce that at runtime, WARNing and falling back to a harmless "kthread/%u" in case verification fails. Signed-off-by: Rasmus Villemoes --- kernel/kthread.c | 4 ++-- 1 file changed, 2

[RFC PATCH 2/7] lib/vsprintf.c: add fmtcheck utility

2018-10-26 Thread Rasmus Villemoes
ever appear in a hot path. The BSDs (and libbsd on linux) contain a fmtcheck() function; I took the name and return semantics from that. Signed-off-by: Rasmus Villemoes --- include/linux/kernel.h | 18 lib/Kconfig.debug | 9 ++ lib/vsprintf.c | 65 ++

[RFC PATCH 1/7] compiler_attributes.h: add __attribute__((format_arg)) shorthand

2018-10-26 Thread Rasmus Villemoes
mpiler cannot do any type checking. Even a static inline fmtcheck() that just returns its first argument would provide documentation for which specifiers what->ever is supposed to contain, but we'll implement an actual run-time check later. Signed-off-by: Rasmus Villemoes --- include/lin

[RFC PATCH 6/7] nfs: use fmtcheck() in root_nfs_data

2018-10-26 Thread Rasmus Villemoes
check of fmt to ensure it doesn't contain odd printf specifiers that would make snprintf go off into the weeds. The lack of the FMTCHECK_NO_EXTRA_ARGS flag (i.e., the last 0 argument) means we allow either no specifiers or precisely one occurrence of %s in tmp. Signed-off-by: Rasmus Vi

[RFC PATCH 4/7] lib/test_printf.c: add a few fmtcheck() test cases

2018-10-26 Thread Rasmus Villemoes
It should be trivial to add more test cases, once we figure out the exact rules for being compatible or not. Perhaps we'll have to extend the struct test with a flags element if we add flags that affect the return value. Signed-off-by: Rasmus Villemoes --- lib/test_printf.c

Re: [PATCH 1/2] string: make kmemdup_nul take and return void*, not char*

2018-09-18 Thread Rasmus Villemoes
On 7 September 2018 at 09:46, Rasmus Villemoes wrote: > This allows kmemdup_nul to be used in cases where the source pointer is > not a char* or const char*, but the result should nevertheless have a > nul char after the memcpy'ed data. ping

Re: [PATCH] x86: Avoid pr_cont() in show_opcodes()

2018-07-17 Thread Rasmus Villemoes
On 2018-07-07 15:54, Tetsuo Handa wrote: > On 2018/07/07 20:12, Ingo Molnar wrote: >> >> * Tetsuo Handa wrote: >> >>> From: Tetsuo Handa >>> >>> Since syzbot is confused by concurrent printk() messages [1], >>> this patch changes show_opcodes() to use snprintf(). >>> >>> When we start adding pref

Re: [PATCH] x86: Avoid pr_cont() in show_opcodes()

2018-07-17 Thread Rasmus Villemoes
On 2018-07-17 15:53, Tetsuo Handa wrote: > On 2018/07/17 18:01, Rasmus Villemoes wrote: >> Why not this instead? Less stack use, less code, no intermediary >> snprintfs, no pr_cont... > > Excellent! I didn't notice %ph extension. > >> Not compile-tested, proba

[PATCH] docs: admin-guide: update description for kernel.modprobe sysctl

2021-04-20 Thread Rasmus Villemoes
When I added CONFIG_MODPROBE_PATH, I neglected to update Documentation/. It's still true that this defaults to /sbin/modprobe, but now via a level of indirection. So document that the kernel might have been built with something other than /sbin/modprobe as the initial value. Signed-off-by: R

Re: [PATCH v6 01/27] mm: Introduce struct folio

2021-04-08 Thread Rasmus Villemoes
On 31/03/2021 20.47, Matthew Wilcox (Oracle) wrote: > +static inline void folio_build_bug(void) > +{ > +#define FOLIO_MATCH(pg, fl) \ > +BUILD_BUG_ON(offsetof(struct page, pg) != offsetof(struct folio, fl)); > + > + FOLIO_MATCH(flags, flags); > + FO

Re: [PATCH v1 1/1] kernel.h: Split out panic and oops helpers

2021-04-08 Thread Rasmus Villemoes
On 06/04/2021 15.31, Andy Shevchenko wrote: > kernel.h is being used as a dump for all kinds of stuff for a long time. > Here is the attempt to start cleaning it up by splitting out panic and > oops helpers. Yay. Acked-by: Rasmus Villemoes > At the same time convert users in he

[PATCH 1/2] lib/lcm.c: Ensure correct result whenever it fits

2014-12-09 Thread Rasmus Villemoes
Ensure that lcm(a,b) returns the mathematically correct result, provided it fits in an unsigned long. The current version returns garbage if a*b overflows, even if the final result would fit. Signed-off-by: Rasmus Villemoes --- lib/lcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

[PATCH 2/2] lib/lcm.c: lcm(n,0)=lcm(0,n) is 0, not n

2014-12-09 Thread Rasmus Villemoes
Return the mathematically correct answer when an argument is 0. Signed-off-by: Rasmus Villemoes --- lib/lcm.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/lcm.c b/lib/lcm.c index 01b3aa922dda..51cc6b13cd52 100644 --- a/lib/lcm.c +++ b/lib/lcm.c @@ -8,9 +8,7

[PATCH] ASoC: soc-dapm: Fix comparison of pointers

2014-12-09 Thread Rasmus Villemoes
The idiom 'return a - b;' often used in comparison functions is wrong unless one is certain the values being compared lie in a sufficiently small range. In this case dapm_seq_compare would also return 0 if the ->dapm pointers happened to differ by a multiple of 2^32. Signed-o

[PATCH] fs: hfs: Fix comparison bug in hfs_cat_keycmp

2014-12-10 Thread Rasmus Villemoes
than a. One can also easily find three values a,b,c such that a compares less than b, b compares less than c, but a does not compare less than c. Signed-off-by: Rasmus Villemoes --- fs/hfs/catalog.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/hfs

[PATCH] lib: Remove strnicmp

2014-12-11 Thread Rasmus Villemoes
Now that all in-tree users of strnicmp have been converted to strncasecmp, the wrapper can be removed. Signed-off-by: Rasmus Villemoes --- Notes: For 3.20. The "#undef __HAVE_ARCH_STRNICMP" in arch/s390/include/asm/string.h is a no-op, so removing it should be ok

Re: [PATCH 3/3] ACPICA: Remove use of __DATE__ macro

2015-01-05 Thread Rasmus Villemoes
On Mon, Jan 05 2015, "Zheng, Lv" wrote: > Hi, > >> From: Rasmus Villemoes [mailto:li...@rasmusvillemoes.dk] >> Sent: Friday, December 12, 2014 6:51 PM >> To: Zheng, Lv >> Cc: Rasmus Villemoes; linux-a...@vger.kernel.org; de...@acpica.org; >> linux

[PATCH] fbdev: omap2: Fix typo in tvc_probe_pdata

2015-01-05 Thread Rasmus Villemoes
Assigning ddata->invert_polarity to itself is not very useful; the context suggests that the right-hand side should have been pdata->invert_polarity. Signed-off-by: Rasmus Villemoes --- drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c | 2 +- 1 file changed, 1 insertion

[PATCH] net: tulip: Remove private "strncmp"

2014-12-04 Thread Rasmus Villemoes
cmp is actually a memcmp (except for the signature and that bytes are not necessarily treated as unsigned char); since only the boolean value of the result is used we can just replace de4x5_strncmp with memcmp. Signed-off-by: Rasmus Villemoes --- Notes: I don't know if the comment mean

[PATCH] fs: nfsd: Fix bug in compare_blob

2014-12-04 Thread Rasmus Villemoes
long)o1->len - (long long)o2->len; but I'd rather eliminate the usually broken 'return a - b;' idiom. Signed-off-by: Rasmus Villemoes --- Notes: How this could ever have worked is beyond me - compare_blob seems to be used to maintain an rbtree, and I wouldn't ex

[PATCH] kernfs: Fix kernfs_name_compare

2014-12-04 Thread Rasmus Villemoes
slightly subtle and since returning hash - kn->hash in the first place is only ok because the hashes are restricted to 31 bits, add a comment explaining that. Signed-off-by: Rasmus Villemoes --- fs/kernfs/dir.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git

[PATCH v2] fs: nfsd: Fix signedness bug in compare_blob

2014-12-05 Thread Rasmus Villemoes
long)o1->len - (long long)o2->len; but I'd rather eliminate the usually broken 'return a - b;' idiom. Reviewed-by: Jeff Layton Cc: Signed-off-by: Rasmus Villemoes --- Notes: How this could ever have worked is beyond me - compare_blob seems to be used to maintain an rbtr

[PATCH v2] kernfs: Fix kernfs_name_compare

2014-12-05 Thread Rasmus Villemoes
ns 0, falsely reporting a match to the caller. Technically 'hash - kn->hash' is ok since the hashes are restricted to 31 bits, but it's better to avoid that subtlety. Signed-off-by: Rasmus Villemoes --- Notes: v2: Also use explicit < > comparisons of the hashes. fs/k

[PATCH 1/2] MPILIB: Fix comparison of negative MPIs

2014-12-05 Thread Rasmus Villemoes
If u and v both represent negative integers and their limb counts happen to differ, mpi_cmp will always return a positive value - this is obviously bogus. u is smaller than v if and only if it is larger in absolute value. Signed-off-by: Rasmus Villemoes --- lib/mpi/mpi-cmp.c | 2 +- 1 file

[PATCH 2/2] MPILIB: Deobfuscate mpi_cmp

2014-12-05 Thread Rasmus Villemoes
s ok since mpihelp_cmp returns {-1,0,1}; -INT_MIN==INT_MIN won't bite us. Signed-off-by: Rasmus Villemoes --- lib/mpi/mpi-cmp.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/mpi/mpi-cmp.c b/lib/mpi/mpi-cmp.c index 3801694240d8..d25e9e96c310 100644 --- a/lib/mpi/mpi-

Re: [PATCH 3/20] PCI: fix misspelling of current function in string

2014-12-07 Thread Rasmus Villemoes
On Sun, Dec 07 2014, Julia Lawall wrote: > Replace a misspelled function name by %s and then __func__. > > The function name begins with pci, not cpci. ... > result = cpci_hotplug_init(debug); > if (result) { > - err("cpci_hotplug_init with error %d\n", result); > +

[PATCH] drm/i915: Fix comparison bug

2014-12-07 Thread Rasmus Villemoes
->stolen->start has type unsigned long; relying on the difference (effectively cast to int) for sorting is wrong. Signed-off-by: Rasmus Villemoes --- drivers/gpu/drm/i915/i915_debugfs.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_deb

Re: [Ocfs2-devel] [PATCH 1/1 linux-next] ocfs2: remove unnecessary sizeof(char)

2014-12-23 Thread Rasmus Villemoes
On Mon, Dec 22 2014, Andrew Morton wrote: > On Mon, 22 Dec 2014 20:05:09 +0100 Fabian Frederick wrote: > >> >> -replay_map = kzalloc(sizeof(struct ocfs2_replay_map) + >> - (osb->max_slots * sizeof(char)), GFP_KERNEL); >> +replay_map = kzalloc(sizeof(struct ocfs2

[PATCH 15/19] lib/sort.c: Move include inside #if 0

2014-12-30 Thread Rasmus Villemoes
The sort function and its helpers don't do memory allocation, so the slab.h include is redundant. Move it inside the #if 0 protecting the self-test, similar to how it is done in lib/list_sort.c. This removes over 450 lines from the generated dependency file. Signed-off-by: Rasmus Vill

[PATCH 06/19] lib/genalloc.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
Removing this include produces byte-identical output, and thus removes a false dependency. Signed-off-by: Rasmus Villemoes --- lib/genalloc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/genalloc.c b/lib/genalloc.c index 2e65d206b01c..17d8f58f6716 100644 --- a/lib/genalloc.c +++ b/lib

[PATCH 19/19] lib/lcm.c: Replace include

2014-12-30 Thread Rasmus Villemoes
We don't need all the stuff kernel.h pulls in; just compiler.h since export.h doesn't do necessary #includes. This removes more than 100 dependencies. Signed-off-by: Rasmus Villemoes --- lib/lcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lcm.c b/lib/l

[PATCH 16/19] lib/stmp_device.c: Replace module.h include

2014-12-30 Thread Rasmus Villemoes
stmp_device.c only needs EXPORT_SYMBOL, so just include compiler.h and export.h instead of the whole module.h machinery. Signed-off-by: Rasmus Villemoes --- lib/stmp_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stmp_device.c b/lib/stmp_device.c index

[PATCH 17/19] lib/strncpy_from_user.c: Replace module.h include

2014-12-30 Thread Rasmus Villemoes
strncpy_from_user.c only needs EXPORT_SYMBOL, so just include compiler.h and export.h instead of the whole module.h machinery. Signed-off-by: Rasmus Villemoes --- lib/strncpy_from_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/strncpy_from_user.c b/lib

[PATCH 10/19] lib/kobject_uevent.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
The file doesn't seem to use anything from linux/user_namespace.h, and removing it yields byte-identical object code and strictly fewer dependencies in the .cmd file. Signed-off-by: Rasmus Villemoes --- lib/kobject_uevent.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/kobject_uev

[PATCH 18/19] lib/percpu_ida.c: Remove redundant includes

2014-12-30 Thread Rasmus Villemoes
. Signed-off-by: Rasmus Villemoes --- lib/percpu_ida.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c index 93d145e5539c..f75715131f20 100644 --- a/lib/percpu_ida.c +++ b/lib/percpu_ida.c @@ -19,13 +19,10 @@ #include #include #include -#include

[PATCH 12/19] lib/plist.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
Removing the include of linux/spinlock.h produces byte-identical output for {allno,def}config, and identical objdump -d output for allyesconfig. In the former two cases, more than a 100 lines are eliminated from the generated dependency file. Signed-off-by: Rasmus Villemoes --- lib/plist.c | 1

[PATCH 13/19] lib/radix-tree.c: Change to simpler include

2014-12-30 Thread Rasmus Villemoes
The comment helpfully explains why hardirq.h is included, but since 2d4b84739f0a ("hardirq: Split preempt count mask definitions") in_interrupt() has been provided by preempt_mask.h. Use that instead, saving around 40 lines in the generated dependency file. Signed-off-by: Rasmus

[PATCH 14/19] lib/show_mem.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
show_mem.c doesn't use anything from nmi.h. Removing it yields identical objdump -d output for each of {allyes,allno,def}config and eliminates more than 100 lines in the dependency file. Signed-off-by: Rasmus Villemoes --- lib/show_mem.c | 1 - 1 file changed, 1 deletion(-) diff --git

[PATCH 11/19] lib/nlattr.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
nlattr.c doesn't seem to rely on anything from netdevice.h. Removing it yields identical objdump -d output for each of {allyes,allno,def}config, and eliminates more than 200 lines from the generated dependency file. Signed-off-by: Rasmus Villemoes --- lib/nlattr.c | 1 - 1 file chang

[PATCH 05/19] lib/idr.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
idr.c doesn't seem to use anything from hardirq.h (or anything included from that). Removing it produces identical objdump -d output, and gives 44 fewer lines in the .idr.o.cmd dependency file. Signed-off-by: Rasmus Villemoes --- lib/idr.c | 1 - 1 file changed, 1 deletion(-) diff --git

[PATCH 09/19] lib/llist.c: Remove redundant include

2014-12-30 Thread Rasmus Villemoes
This file doesn't seem to use anything provided by linux/interrupt.h or anything recursively included through that. Removing it produces byte-identical output, while reducing .llist.o.cmd from 541 to 156 lines. Signed-off-by: Rasmus Villemoes --- lib/llist.c | 1 - 1 file changed, 1 del

[PATCH 08/19] lib/md5.c: Simplify include

2014-12-30 Thread Rasmus Villemoes
md5.c doesn't use anything from kernel.h, except that that pulls in compiler.h, which is needed for the export.h to work. Signed-off-by: Rasmus Villemoes --- lib/md5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/md5.c b/lib/md5.c index 958a3c15923c..bb0cd01

[PATCH 02/19] lib/sort.c: Use simpler includes

2014-12-30 Thread Rasmus Villemoes
file .sort.o.cmd. Signed-off-by: Rasmus Villemoes --- lib/sort.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sort.c b/lib/sort.c index 926d00429ed2..14fc1dfadb3f 100644 --- a/lib/sort.c +++ b/lib/sort.c @@ -4,8 +4,8 @@ * Jan 23 2005 Matt Mackall */ -#in

[PATCH 07/19] lib/list_sort.c: Rearrange includes

2014-12-30 Thread Rasmus Villemoes
mic_debug.h, but only if !CONFIG_DYNAMIC_DEBUG, so just include it explicitly (for memset). objdump -d says the generated code is the same, and wc -l says that lib/.list_sort.o.cmd went from 579 to 165 lines. Signed-off-by: Rasmus Villemoes --- lib/list_sort.c | 7 +-- 1 file changed, 5

[PATCH 04/19] lib/halfmd4.c: Simplify includes

2014-12-30 Thread Rasmus Villemoes
/types.h in order for gcc not to complain about unknown types. Signed-off-by: Rasmus Villemoes --- include/linux/cryptohash.h | 2 ++ lib/halfmd4.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/cryptohash.h b/include/linux/cryptohash.h index

[PATCH 01/19] lib/interval_tree.c: Simplify includes

2014-12-30 Thread Rasmus Villemoes
The file uses nothing from init.h, and also doesn't need the full module.h machinery; export.h is sufficient. The latter requires the user to ensure compiler.h is included, so do that explicitly instead of relying on some other header pulling it in. Signed-off-by: Rasmus Villemoes ---

[PATCH 00/19] lib: Some #include cleanups

2014-12-30 Thread Rasmus Villemoes
gain from removing includes from .h files, but that is of course at the same time a huge can of worms, involving boatloads of tree-wide patches updating users to include what they use directly. So before I start doing that, I'd like to hear if people think it would be futile. Rasmus Villemo

[PATCH 03/19] lib/dynamic_queue_limits.c: Simplify includes

2014-12-30 Thread Rasmus Villemoes
The file doesn't use anything from ctype.h. Instead of module.h, just use export.h for EXPORT_SYMBOL. The latter requires the user to include compiler.h, so do that explicitly instead of relying on some other header pulling it in. Signed-off-by: Rasmus Villemoes --- lib/dynamic_queue_lim

[PATCH 1/2] lib/bitmap.c: Change prototype of bitmap_copy_le

2014-12-30 Thread Rasmus Villemoes
s can pass their u8 or __le32 buffers without a cast. Furthermore, this allows us to simply let bitmap_copy_le be an alias for bitmap_copy on little-endian; see next patch. Signed-off-by: Rasmus Villemoes --- include/linux/bitmap.h | 2 +- lib/bitmap.c | 9 - 2 files changed, 5

[PATCH 2/2] lib/bitmap.c: Elide bitmap_copy_le on little-endian

2014-12-30 Thread Rasmus Villemoes
On little-endian, there's no reason to have an extra, presumably less efficient, way of copying a bitmap. Signed-off-by: Rasmus Villemoes --- include/linux/bitmap.h | 4 lib/bitmap.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/linux/bitmap.h b/include/

[PATCH] perf/tests: Fix typo in sample-parsing.c

2015-01-22 Thread Rasmus Villemoes
I'm pretty sure this wasn't supposed to be dead code. Signed-off-by: Rasmus Villemoes --- tools/perf/tests/sample-parsing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index 4908c648a597..30

[PATCH 1/2] drivers/hwmon/ad7314.c: Do proper sign extension

2015-01-22 Thread Rasmus Villemoes
rks equally well for 8 and 16 bit types. Signed-off-by: Rasmus Villemoes --- drivers/hwmon/ad7314.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c index f4f9b219bf16..11955467fc0f 100644 --- a/drivers/hwmon/ad7314.c +++ b/driv

[PATCH 2/2] drivers/hwmon/adc128d818.c: Do proper sign extension

2015-01-22 Thread Rasmus Villemoes
data->temp[index] has type s16. Because of C's promotion rules, (data->temp[index] << 7) >> 7 is exactly the same as data->temp[index]. The intention was to use bit 8 as a sign bit, so do that using the existing API. Signed-off-by: Rasmus Villemoes --- drivers/hwmon/ad

[PATCH] ethernet: fm10k: Actually drop 4 bits

2015-01-22 Thread Rasmus Villemoes
The comment explains the intention, but vid has type u16. Before the inner shift, it is promoted to int, which has plenty of space for all vid's bits, so nothing is dropped. Use a simple mask instead. Signed-off-by: Rasmus Villemoes --- drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +- 1

[PATCH] staging: iio: ad2s1200: Fix sign extension

2015-01-22 Thread Rasmus Villemoes
xtend32 works equally well for 8 and 16 bits types, so use that. Signed-off-by: Rasmus Villemoes --- drivers/staging/iio/resolver/ad2s1200.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c in

[PATCH] iio: imu: adis16400: Fix sign extension

2015-01-22 Thread Rasmus Villemoes
The intention is obviously to sign-extend a 12 bit quantity. But because of C's promotion rules, the assignment is equivalent to "val16 &= 0xfff;". Use the proper API for this. Signed-off-by: Rasmus Villemoes --- drivers/iio/imu/adis16400_core.c | 3 ++- 1 file changed,

[PATCH] atheros/atlx: Simplify bit manipulations

2015-01-23 Thread Rasmus Villemoes
'foo |= X;'. In the atl2 case, gcc does know how to merge the new adjacent operations, so altogether this gives a nice little code size reduction of about 80 bytes. Signed-off-by: Rasmus Villemoes --- drivers/net/ethernet/atheros/atlx/atl1.c | 3 +-- drivers/net/ethernet/atheros/atlx

Re: [PATCH] lib: find_*_bit reimplementation

2015-01-23 Thread Rasmus Villemoes
On Mon, Jan 19 2015, Yury Norov wrote: > New implementation takes less space, and, I hope, easier to understand. > > Signed-off-by: Yury Norov > --- > lib/find_next_bit.c | 265 > +++- > 1 file changed, 73 insertions(+), 192 deletions(-) > That

Re: [PATCH] ethernet: fm10k: Actually drop 4 bits

2015-01-23 Thread Rasmus Villemoes
On Sat, Jan 24 2015, "Vick, Matthew" wrote: > Good catch! I noticed this too and was getting a patch together to address > this. > > The difference is that I was planning on not silently accepting an invalid > VLAN ID to begin with and returning FM10K_ERR_PARAM if the VLAN was > invalid, which I

Re: [RFC][PATCH] procfs: Add /proc//mapped_files

2015-01-14 Thread Rasmus Villemoes
On Wed, Jan 14 2015, Calvin Owens wrote: > Commit b76437579d1344b6 ("procfs: mark thread stack correctly in > proc//maps") introduced logic to mark thread stacks with the > "[stack:%d]" marker in /proc//maps. > > This causes reading /proc//maps to take O(N^2) time, where N is > the number of thre

Re: [RFC][PATCH] procfs: Add /proc//mapped_files

2015-01-14 Thread Rasmus Villemoes
On Wed, Jan 14 2015, Siddhesh Poyarekar wrote: > On 14 January 2015 at 19:43, Rasmus Villemoes > wrote: >> Just thinking out loud: Could one simply mark a VMA as being used for >> stack during the clone call (is there room in vm_flags, or does >> VM_GROWSDOWN alre

[PATCH] lib/string.c: Improve strrchr

2015-01-14 Thread Rasmus Villemoes
Instead of potentially passing over the string twice in case c is not found, just keep track of the last occurrence. According to bloat-o-meter, this also cuts the generated code by a third (54 vs 36 bytes). Oh, and we get rid of those 7-space indented lines. Signed-off-by: Rasmus Villemoes

Re: [RFC][PATCH] procfs: Add /proc//mapped_files

2015-01-14 Thread Rasmus Villemoes
On Wed, Jan 14 2015, Andrew Morton wrote: > On Wed, 14 Jan 2015 13:03:26 -0800 Calvin Owens wrote: >> >> If I understand the current behavior, the "[stack]" marker will get put >> next to *any* mapping that encompasses the current value in the task's >> %sp, regardless of how the mapping was cr

[PATCH 3/4] lib/vsprintf.c: Don't try to fix pointer wrap-around

2015-01-08 Thread Rasmus Villemoes
Actual kernel buffers can't wrap into the user address space. If someone manages to pass a buf/size combination that wraps, it is most likely due to a bug in the caller. Instead of trying to fix it by using a smaller part of the buffer, bail out. Signed-off-by: Rasmus Villemoes ---

[PATCH 2/4] lib/vsprintf.c: Improve sanity check in vsnprintf()

2015-01-08 Thread Rasmus Villemoes
On 64 bit, size may very well be huge even if bit 31 happens to be 0. Somehow it doesn't feel right that one can pass a 5 GiB buffer but not a 3 GiB one. So cap at INT_MAX as was probably the intention all along. This is also the made-up value passed by sprintf and vsprintf. Signed-off-by: R

[PATCH 4/4] lib/vsprintf.c: Replace while with do-while in skip_atoi

2015-01-08 Thread Rasmus Villemoes
All callers of skip_atoi have already checked for the first character being a digit. In this case, gcc generates simpler code for a do while-loop. Signed-off-by: Rasmus Villemoes --- lib/vsprintf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib

[PATCH 1/4] lib/vsprintf.c: Consume 'p' in format_decode

2015-01-08 Thread Rasmus Villemoes
It seems a little simpler to consume the p from a %p specifier in format_decode, just as it is done for the surrounding %c, %s and %% cases. While there, delete a redundant and misplaced comment. Signed-off-by: Rasmus Villemoes --- lib/vsprintf.c | 7 +++ 1 file changed, 3 insertions(+), 4

[PATCH] MPILIB: Fix obvious but harmless typo

2015-01-09 Thread Rasmus Villemoes
The macro MPN_COPY_INCR this occurs in isn't used anywhere. Signed-off-by: Rasmus Villemoes --- Another small thing I stumbled on. lib/mpi/mpi-internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mpi/mpi-internal.h b/lib/mpi/mpi-internal.h index 60cf765

[PATCH] net: wireless: atmel: Remove open-coded and wrong strcasecmp

2015-01-16 Thread Rasmus Villemoes
ed as equal. Signed-off-by: Rasmus Villemoes --- drivers/net/wireless/atmel.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 9183f1cf89a7..55db9f03eb2a 100644 --- a/drivers/net/wireless/atmel.c

[PATCH 1/2] infiniband: Help gcc generate better code for ocrdma_srq_toggle_bit

2015-01-16 Thread Rasmus Villemoes
a few useless instructions might be worthwhile. Signed-off-by: Rasmus Villemoes --- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index

[PATCH 2/2] infiniband: Use unsigned for bit index

2015-01-16 Thread Rasmus Villemoes
unsigned - this cuts another few instructions from the generated code. Signed-off-by: Rasmus Villemoes --- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma

Re: Issue with 'lib/vsprintf.c: don't try to fix pointer wrap-around'

2015-01-16 Thread Rasmus Villemoes
On Fri, Jan 16 2015, Andrew Morton wrote: > On Fri, 16 Jan 2015 11:23:57 -0500 Johannes Weiner wrote: > >> Hi Rasmus, >> >> I have trouble booting my test machine with this patch in -mm: >> >> commit bb2e066c6943e62e9650bb129f416dacf138f8b1 >> Autho

[RFC/PATCH] init/main.c: Simplify initcall_blacklisted()

2015-01-16 Thread Rasmus Villemoes
on the stack, that might as well be done up here. Signed-off-by: Rasmus Villemoes --- Notes: I don't know how expensive it is to do the symbol lookup for each initcall. It might be worthwhile adding an if (list_empty(&blacklisted_initcalls)) return false;

[PATCH 0/2] Two printf fixes

2015-01-28 Thread Rasmus Villemoes
vsnprintf would still not reflect the actual size needed. For %pE, this requires a change of semantics of string_escape_mem and hence an annoyingly large diffstat. Whether this is 3.20, 3.21 and/or -stable material (or /dev/null material, for that matter ;-)) I'll leave to others to decide. R

[PATCH 2/2] string_helpers: Change semantics of string_escape_mem

2015-01-28 Thread Rasmus Villemoes
eems to work. In test-string_helpers.c, I removed the now meaningless -ENOMEM test, and replaced it with testing for getting the expected return value even if the buffer is too small. Also ensure that nothing is written when osz==0. In net/sunrpc/cache.c, I think qword_add still has the same semantic

Re: [PATCH 1/2] lib/vsprintf.c: Fix potential NULL deref in hex_string

2015-01-28 Thread Rasmus Villemoes
On Wed, Jan 28 2015, Andy Shevchenko wrote: > On Wed, 2015-01-28 at 14:25 +0100, Rasmus Villemoes wrote: >> The helper hex_string() is broken in two ways. First, it doesn't >> increment buf regardless of whether there is room to print, so callers >> such as kasprin

[PATCH 1/2] lib/vsprintf.c: Fix potential NULL deref in hex_string

2015-01-28 Thread Rasmus Villemoes
P_KERNEL, "%14ph", "CrashBoomBang"). Nobody seems to be using %ph with kasprintf, but we might as well fix it before it hits someone. Signed-off-by: Rasmus Villemoes --- lib/vsprintf.c | 23 ++- 1 file changed, 18 insertions(+), 5 deletions(-) diff

[PATCH] fs: cleanup slight list_entry abuse

2015-03-19 Thread Rasmus Villemoes
list_entry is just a wrapper for container_of, but it is arguably wrong (and slightly confusing) to use it when the pointed-to struct member is not a struct list_head. Use container_of directly instead. Signed-off-by: Rasmus Villemoes --- Most of these predate git. If I'm the only one wh

Re: [PATCH v1] lib/vsprintf.c: Even faster decimal conversion

2015-03-19 Thread Rasmus Villemoes
On Wed, Mar 11 2015, Andrew Morton wrote: > On Wed, 11 Mar 2015 00:01:11 +0100 Rasmus Villemoes > wrote: >> Test and verification code on github >> <https://github.com/Villemoes/dec>. It would be nice if someone could >> verify the code on architectures oth

[PATCH] lib/vsprintf.c: improve put_dec_trunc8 slightly

2015-03-19 Thread Rasmus Villemoes
load/store pair. It also shaves 16 bytes of .text. Signed-off-by: Rasmus Villemoes --- lib/vsprintf.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e0bea9e5bbbf..7078d90c187b 100644 --- a/lib/vsprintf.c +++ b/lib/vspri

Re: + lib-vsprintfc-even-faster-decimal-conversion.patch added to -mm tree

2015-03-19 Thread Rasmus Villemoes
On Thu, Mar 19 2015, Alexey Dobriyan wrote: > On Wed, Mar 18, 2015 at 1:04 AM, Andrew Morton > wrote: >> On Mon, 16 Mar 2015 18:19:41 +0300 Alexey Dobriyan >> wrote: >> >>> Rasmus, I redid benchmarks: >> >> tl;dr ;) Is this an ack or a nack? > > New code executes slower for some input on one

[PATCH] kbuild: include core debug info when DEBUG_INFO_REDUCED

2015-03-20 Thread Rasmus Villemoes
mit-struct-debug-baseonly. This increases the size of .debug_info by ~0.3%, but these 90 KB contain some rather useful info. Signed-off-by: Rasmus Villemoes --- lib/Makefile | 3 +++ lib/debug_info.c | 27 +++ 2 files changed, 30 insertions(+) create mode

Re: [PATCH v2] mm/slab_common: Support the slub_debug boot option on specific object size

2015-04-23 Thread Rasmus Villemoes
On Wed, Apr 22 2015, Gavin Guo wrote: > /* > + * The kmalloc_names is for temporary usage to make > + * slub_debug=,kmalloc-xx option work in the boot time. The > + * kmalloc_index() support to 2^26=64MB. So, the final entry of the > + * table is kmalloc-67108864. > +

[PATCH] linux/slab.h: fix three off-by-one typos in comment

2015-04-23 Thread Rasmus Villemoes
The first is a keyboard-off-by-one, the other two the ordinary mathy kind. Signed-off-by: Rasmus Villemoes --- include/linux/slab.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index ffd24c830151..a99f0e5243e1 100644 --- a

<    1   2   3   4   5   6   7   8   9   10   >