[PATCH 2/2] x86: dumpstack: eliminate some #ifdefs

2015-10-06 Thread Rasmus Villemoes
Jiri Slaby noted that these #ifdef protected printks should really be pr_cont. However, we might as well get completely rid of both the multiple printk calls and the tiny #ifdef sections by just building an appropriate string and passing that to the first printk call. Signed-off-by: Rasmus

Re: [PATCH] string: Improve the generic strlcpy() implementation

2015-10-06 Thread Rasmus Villemoes
On Tue, Oct 06 2015, Ingo Molnar <mi...@kernel.org> wrote: > * Rasmus Villemoes <li...@rasmusvillemoes.dk> wrote: > >> >> I'm not against making strlcpy more robust, but I think the theoretical race >> is >> far more likely to manifest through a memb

Re: [PATCH] string: Improve the generic strlcpy() implementation

2015-10-09 Thread Rasmus Villemoes
On Thu, Oct 08 2015, Ingo Molnar wrote: > * Linus Torvalds wrote: > >> So I really refuse to worry about the snprintf() family of functions wrt >> this >> race. I don't think it was hugely important for strlcpy() either - more of a >> "quality

Re: slab.h debugging tags....

2015-10-09 Thread Rasmus Villemoes
On Fri, Oct 09 2015, Valdis Kletnieks <valdis.kletni...@vt.edu> wrote: > Author: Rasmus Villemoes <li...@rasmusvillemoes.dk> > Date: Wed Oct 7 15:09:20 2015 +1100 > > slab.h: sprinkle __assume_aligned attributes > > causes *tons* of whinges if you d

[PATCH] linux/clock_cooling.h: use unique include guard

2015-10-12 Thread Rasmus Villemoes
Using the same include guard as linux/cpu_cooling.h will cause build breakage if those headers are ever used from the same TU. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/clock_cooling.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff

[PATCH] x86, fpu: put a few variables in .init.data

2015-11-13 Thread Rasmus Villemoes
These are clearly just used during init. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- arch/x86/kernel/fpu/init.c | 4 ++-- arch/x86/kernel/fpu/xstate.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kern

[PATCH] mei: bus: use scnprintf in *_show

2015-11-14 Thread Rasmus Villemoes
There's no reason to duplicate the logic provided by scnprintf(). Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/misc/mei/bus.c | 19 --- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c

[PATCH] HID: core: use scnprintf in modalias_show()

2015-11-14 Thread Rasmus Villemoes
scnprintf() exists to provide these semantics, so we might as well use it. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/hid/hid-core.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c

Re: [PATCH] lib: Make _find_next_bit helper function inline

2015-08-30 Thread Rasmus Villemoes
I've lost track of what's up and down in this, but now that I look at this again let me throw in my two observations of stupid gcc behaviour: For the current code, both debian's gcc (4.7) and 5.1 partially inlines _find_next_bit, namely the if (!nbits || start = nbits) test. I know it does it to

Re: incoming

2015-09-10 Thread Rasmus Villemoes
On Thu, Sep 10 2015, Linus Torvalds wrote: > The VERY FIRST conversion patch I looked at was buggy. That makes me > angry. The whole *AND*ONLY* point of this whole thing was to get rid > of bugs, and be a obviously safe interface, and then the first > conversion

Re: [PATCH] lib/vsprintf.c: increase the size of the field_width variable

2015-09-10 Thread Rasmus Villemoes
On Thu, Sep 10 2015, Joe Perches <j...@perches.com> wrote: > On Thu, 2015-09-10 at 09:04 +0200, Maurizio Lombardi wrote: >> Hi Rasmus, >> >> On 09/09/2015 08:51 PM, Rasmus Villemoes wrote: >> > I'm also a little confused; I don't see what printk has to do

[PATCH 1/4] net: cavium: liquidio: use kzalloc in setup_glist()

2015-09-09 Thread Rasmus Villemoes
We save a little .text and get rid of the sizeof(...) style inconsistency. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/net/ethernet/cavium/liquidio/lio_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/li

[PATCH 3/4] net: mv643xx_eth: use kzalloc

2015-09-09 Thread Rasmus Villemoes
The double memset is a little ugly; using kzalloc avoids it altogether. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/net/ethernet/marvell/mv643xx_eth.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/mv643xx_et

[PATCH 0/4] net: a few kzalloc/memset cleanups

2015-09-09 Thread Rasmus Villemoes
These are just a few k[czm]alloc/memset related cleanups. Rasmus Villemoes (4): net: cavium: liquidio: use kzalloc in setup_glist() net: jme: use kzalloc() instead of kmalloc+memset net: mv643xx_eth: use kzalloc net: qlcnic: delete redundant memsets drivers/net/ethernet/cavium/liquidio

[PATCH 2/4] net: jme: use kzalloc() instead of kmalloc+memset

2015-09-09 Thread Rasmus Villemoes
Using kzalloc saves a tiny bit on .text. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/net/ethernet/jme.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 6e9a792097d3..060dd3

[PATCH 4/4] net: qlcnic: delete redundant memsets

2015-09-09 Thread Rasmus Villemoes
In all cases, mbx->req.arg and mbx->rsp.arg have just been allocated using kcalloc(), so these six memsets are redundant. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- I cranked $context_lines to 11 to make the kcallocs visible. drivers/net/ethernet/q

[PATCH 3/3] ACPI / scan: use kstrdup_const in acpi_add_id()

2015-09-09 Thread Rasmus Villemoes
Empirically, acpi_add_id is mostly called with string literals, so using kstrdup_const for initializing struct acpi_hardware_id::id saves a little run-time memory and a string copy. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/acpi/scan.c | 4 ++-- 1 file chan

[PATCH 2/3] ACPI: constify struct acpi_hardware_id::id

2015-09-09 Thread Rasmus Villemoes
This is preparation for using kstrdup_const to initialize that member. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/acpi/scan.c| 4 ++-- drivers/pnp/pnpacpi/core.c | 4 ++-- include/acpi/acpi_bus.h| 2 +- 3 files changed, 5 insertions(+), 5 del

[PATCH 1/3] ACPI: constify first argument of struct acpi_scan_handler::match

2015-09-09 Thread Rasmus Villemoes
ing struct acpi_hardware_id::id. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/acpi/acpi_pnp.c | 4 ++-- include/acpi/acpi_bus.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c index c58940b231d6..48f

[PATCH] x86: wmi: Remove private %pUL implementation

2015-09-09 Thread Rasmus Villemoes
so we can eliminate some stack buffers and quite a bit of code by just using %pUL directly. In wmi_dev_uevent I'm not sure whether there's room for a nul-terminator in env->buf, so I've just replaced wmi_gtoa with the equivalent sprintf call. Signed-off-by: Rasmus Villemoes <li...@ra

Re: [PATCH 2/2] kobject: use kvasprintf_const for formatting ->name

2015-09-14 Thread Rasmus Villemoes
On Mon, Sep 14 2015, Andrew Morton <a...@linux-foundation.org> wrote: > On Wed, 9 Sep 2015 23:45:52 +0200 Rasmus Villemoes > <li...@rasmusvillemoes.dk> wrote: > > Do we have other callsites whcih can benefit from switching to > kvasprintf_const()? The [1/2] chang

Re: [PATCH v3 2/2] lib/test-string_helpers.c: add string_get_size() tests

2015-09-14 Thread Rasmus Villemoes
On Mon, Sep 14 2015, Vitaly Kuznetsov wrote: > +static __init void test_string_get_size_one(u64 size, u64 blk_size, > + const enum string_size_units units, > + const char *exp_result) > +{ > +

Re: [RFC PATCH 0/3] fix *pbl format support

2015-09-16 Thread Rasmus Villemoes
On Wed, Sep 16 2015, Maurizio Lombardi wrote: > Hi, > > I tried to fix the "*pb[l]" format issue while taking care of the problems > discussed in this thread: > > https://lkml.org/lkml/2015/9/9/153 > > I would like to know whether this approach is more acceptable to you: > >

Re: [PATCH v4 2/2] lib/test-string_helpers.c: add string_get_size() tests

2015-09-16 Thread Rasmus Villemoes
On Tue, Sep 15 2015, Andy Shevchenko wrote: > On Tue, 2015-09-15 at 15:55 +0200, Vitaly Kuznetsov wrote: >> +static __init void test_string_get_size_one(u64 size, u64 blk_size, >> +const enum >> string_size_units units,

Re: [PATCH] debugfs: don't access 4 bytes for a boolean

2015-09-11 Thread Rasmus Villemoes
On Fri, Sep 11 2015, Viresh Kumar wrote: > Long back 'bool' type used to be a typecast to 'int', but that changed > in v2.6.19. And that is a typecast to _Bool now, which (mostly) takes > just a byte. Anyway, the bool type in kernel is used to store true/false > or 1/0

Re: [RFC PATCH 0/3] fix *pbl format support

2015-09-16 Thread Rasmus Villemoes
sert outside function context?] Only compile-tested. From: Rasmus Villemoes <li...@rasmusvillemoes.dk> Date: Wed, 16 Sep 2015 22:06:14 +0200 Subject: [RFC] lib/vsprintf.c: expand field_width to 24 bits Maurizio Lombardi reported a problem with the %pb extension: It doesn't work for suffic

Re: static key arrays?

2015-09-11 Thread Rasmus Villemoes
On Fri, Sep 11 2015, Johannes Berg wrote: > On Fri, 2015-09-11 at 13:10 +0200, Peter Zijlstra wrote: >> >> struct static_key_false array[n] = { STATIC_KEY_FALSE_INIT, }; >> >> or something like that. > > Yeah, ok, this would be sufficient for me - no need to mix

Re: [PATCH 4/4] test_printf: test printf family at runtime

2015-09-29 Thread Rasmus Villemoes
On Tue, Sep 29 2015, Kees Cook wrote: >> +static void __init >> +test_string(void) >> +{ >> + test("", "%s%.0s", "", "123"); >> + test("ABCD|abc|123", "%s|%.3s|%.*s", "ABCD", "abcdef", 3, "123456"); >> + test("1 | 2|3 | 4|5 ",

Re: [PATCH 1/4] lib/vsprintf.c: handle invalid format specifiers more robustly

2015-09-28 Thread Rasmus Villemoes
On Mon, Sep 28 2015, Andy Shevchenko wrote: >> /* >> - * Since %n poses a greater security risk than >> utility, treat >> - * it as an invalid format specifier. Warn about its >> use so >> - * that new

[PATCH] drm/i915: Fix comparison bug

2015-09-28 Thread Rasmus Villemoes
an int), but 440fd5283a87 ("drm/mm: Support 4 GiB and larger ranges") strongly suggests that's not the case. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/gpu/drm/i915/i915_debugfs.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git

[PATCH v2 3/3] regmap: debugfs: simplify regmap_reg_ranges_read_file() slightly

2015-09-30 Thread Rasmus Villemoes
By printing the newline character to entry, we can avoid accounting for it manually in several places. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/base/regmap/regmap-debugfs.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/driver

[PATCH v2 2/3] regmap: debugfs: use memcpy instead of snprintf

2015-09-30 Thread Rasmus Villemoes
Since we know the length of entry and that there's room enough in the output buffer, using memcpy instead of snprintf is simpler and cheaper. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/base/regmap/regmap-debugfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 del

RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k

2015-09-30 Thread Rasmus Villemoes
arrays in sync. $ scripts/bloat-o-meter /tmp/vmlinux vmlinux add/remove: 2/1 grow/shrink: 1/0 up/down: 7073/-11312 (-4239) Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/scsi/constants.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-)

[PATCH v2 1/3] regmap: debugfs: use snprintf return value in regmap_reg_ranges_read_file()

2015-09-30 Thread Rasmus Villemoes
Calling strlen() no less than three times on entry is silly. Since we're formatting into a buffer with plenty of room, there's no chance of truncation, so snprintf() has actually returned the value we want, meaning we don't even have to call strlen once. Signed-off-by: Rasmus Villemoes <

Re: [PATCH 1/2] regmap: debugfs: remove bogus check

2015-09-30 Thread Rasmus Villemoes
On Tue, Sep 29 2015, Mark Brown <broo...@kernel.org> wrote: > On Tue, Sep 29, 2015 at 12:29:01AM +0200, Rasmus Villemoes wrote: >> snprintf cannot return a negative value (unless map->dev->driver->name >> happens to be over 2G long). So remove the bogus check

Re: [PATCH 4/4] test_printf: test printf family at runtime

2015-09-30 Thread Rasmus Villemoes
m in the first place? Just so we could have this interesting little chat. I don't think it was intentional, but don't worry, they're gone. >> > > +MODULE_AUTHOR("Rasmus Villemoes <li...@rasmusvillemoes.dk>"); >> > > +MODULE_LICENSE("GPL"); >>

[PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()

2015-09-30 Thread Rasmus Villemoes
Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 64b50409fa07..38d910

[PATCH 2/2] drm/omap: use kzalloc in sita_init()

2015-09-30 Thread Rasmus Villemoes
Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/gpu/drm/omapdrm/tcm-sita.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/tcm-sita.c b/drivers/gpu/drm/omapdrm/tcm-sita.c index efb609510540..6df1f2a1bc52

Re: [PATCH] tracing: use kstrdup_const instead of private implementation

2015-09-30 Thread Rasmus Villemoes
On Wed, Sep 09 2015, Rasmus Villemoes <li...@rasmusvillemoes.dk> wrote: ping > The kernel now has kstrdup_const/kfree_const for reusing .rodata > (typically string literals) when possible; there's no reason to > duplicate that logic in the tracing system. Moreover, as the

[RFC 3/4] pid_namespace: make pid_nr_ns and pid_vnr static inlines for !CONFIG_PID_NS

2015-09-30 Thread Rasmus Villemoes
When there is only a single pid namespace, pid_nr_ns and pid_vnr perform the same task as pid_nr, so we can save a little .text by making them simple inlines. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/pid.h | 11 +++ kernel/pid.c| 2 ++ 2

[PATCH] block: nvme-scsi: use kzalloc in nvme_trans_ext_inq_page()

2015-09-30 Thread Rasmus Villemoes
This saves a little .text and is consistent with similar allocations in the rest of the file. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/block/nvme-scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/nvme-scsi.c b/drivers

Re: [PATCH 1/2] drm/vmwgfx: use kzalloc in vmw_surface_define_ioctl()

2015-09-30 Thread Rasmus Villemoes
CH] drm/vmwgfx: check kmalloc return value srf->sizes has been allocated and checked a few lines above; fix up the copy-pasto so that we check srf->offsets. Reported-by: kbuild test robot <l...@intel.com> Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/

Re: [PATCH] trace/ftrace.c: remove redundant swap function

2015-09-30 Thread Rasmus Villemoes
On Wed, Sep 09 2015, Rasmus Villemoes <li...@rasmusvillemoes.dk> wrote: ping > To cover the common case of sorting an array of pointers, Daniel > Wagner recently modified the library sort() to use a specific swap > function for size==8, in addition to the size==4 case which was &g

[RFC 2/4] pid_namespace: remove .kref field for !CONFIG_PID_NS

2015-09-30 Thread Rasmus Villemoes
When there's only one global pid_namespace (init_pid_ns), the kref field is unused (since both get_pid_ns and put_pid_ns are no-ops). While we only save a few bytes by removing it, it could also help catch users manipulating ->kref directly. Signed-off-by: Rasmus Villemoes

[RFC 0/4] reduce pid_namespace footprint when not configured

2015-09-30 Thread Rasmus Villemoes
A few suggestions for reducing the footprint of pid namespaces when CONFIG_PID_NS=n. The savings are admittedly not huge: $ scripts/bloat-o-meter /tmp/vmlinux.master vmlinux add/remove: 0/7 grow/shrink: 30/25 up/down: 368/-1032 (-664) Rasmus Villemoes (4): pid_namespace: remove ->le

[PATCH] vgaarb: use kzalloc in vga_arbiter_add_pci_device()

2015-09-30 Thread Rasmus Villemoes
Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/gpu/vga/vgaarb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index a0b433456107..3166e4bc4eb6 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/d

[RFC 4/4] pid_namespace: disable_pid_allocation is unused for !CONFIG_PID_NS

2015-09-30 Thread Rasmus Villemoes
pid_namespace.c. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- kernel/pid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/pid.c b/kernel/pid.c index d422ddae0484..c9b595517c4f 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -358,12 +358,14 @@ out_free:

[RFC 1/4] pid_namespace: remove ->level and ->parent for !CONFIG_PID_NS

2015-09-30 Thread Rasmus Villemoes
ensure that everyone outside kernel/pid_namespace.c use the new accessors pid_ns_{parent,level}. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/pid_namespace.h | 18 ++ kernel/acct.c | 4 ++-- kernel/pid.c

Re: [PATCH 4/4] test_printf: test printf family at runtime

2015-09-30 Thread Rasmus Villemoes
On Tue, Sep 29 2015, Kees Cook <keesc...@chromium.org> wrote: > On Tue, Sep 29, 2015 at 12:10 AM, Rasmus Villemoes > <li...@rasmusvillemoes.dk> wrote: > >> I guess I could, but do we really want to intentionally trigger >> WARN_ON_ONCEs? Say some distro chooses to

Re: [PATCH 2/2] regmap: debugfs: improve regmap_reg_ranges_read_file()

2015-09-30 Thread Rasmus Villemoes
On Tue, Sep 29 2015, Mark Brown <broo...@kernel.org> wrote: > On Tue, Sep 29, 2015 at 12:29:02AM +0200, Rasmus Villemoes wrote: > > This patch is an example of why SubmittingPatches recommends splitting > things up into one change per patch, it would be much easier to

Re: [RFC 0/4] reduce pid_namespace footprint when not configured

2015-09-30 Thread Rasmus Villemoes
On Wed, Sep 30 2015, ebied...@xmission.com (Eric W. Biederman) wrote: > Rasmus Villemoes <li...@rasmusvillemoes.dk> writes: > >> A few suggestions for reducing the footprint of pid namespaces when >> CONFIG_PID_NS=n. The savings are admittedly not huge: >> &

Re: [PATCH 1/2] regmap: debugfs: remove bogus check

2015-09-30 Thread Rasmus Villemoes
On Wed, Sep 30 2015, Mark Brown <broo...@kernel.org> wrote: > On Wed, Sep 30, 2015 at 09:27:38AM +0200, Rasmus Villemoes wrote: > >> I agree, but only on the word 'great'. There is value in removing such >> bogosities (or rather, their presence provides negative valu

[PATCH] kernel/params.c: remove confusing cast

2015-10-01 Thread Rasmus Villemoes
Both sides of the assignment are const char*, so this cast is unnecessary and confusing. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- kernel/params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/params.c b/kernel/params.c index b6554a

[PATCH] [media] drxd: use kzalloc in drxd_attach()

2015-10-01 Thread Rasmus Villemoes
This saves a little .text and removes the sizeof(...) style inconsistency. Use sizeof(*state) in accordance with CodingStyle. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/media/dvb-frontends/drxd_hard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff

[PATCH] [SCSI] fnic: use kzalloc in fnic_fcoe_process_vlan_resp

2015-10-01 Thread Rasmus Villemoes
This saves a little .text and avoids the sizeof(...) style inconsistency. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/scsi/fnic/fnic_fcs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic

[PATCH] linux/thermal.h: rename KELVIN_TO_CELSIUS to DECI_KELVIN_TO_CELSIUS

2015-10-01 Thread Rasmus Villemoes
The macros KELVIN_TO_CELSIUS and CELSIUS_TO_KELVIN actually convert between deciKelvins and Celsius, so rename them to reflect that. While at it, use a statement expression in DECI_KELVIN_TO_CELSIUS to prevent expanding the argument multiple times and get rid of a few casts. Signed-off-by: Rasmus

Re: RFC: reduce CONFIG_SCSI_CONSTANTS impact by 4k

2015-10-03 Thread Rasmus Villemoes
136 160 +24 additional 113122824 -8488 Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/scsi/constants.c | 25 + drivers/scsi/sense_codes.h | 2 -- 2 files changed, 21 insertions(+), 6 deletions

[PATCH 2/2] slab.h: sprinkle __assume_aligned attributes

2015-10-02 Thread Rasmus Villemoes
with a little overlap. Maybe arches which do not allow unaligned stores gain even more. I don't know if gcc can actually make use of alignments greater than 8 for anything, so one could probably drop the __assume_xyz_alignment macros and just use __assume_aligned(8). Signed-off-by: Rasmus Villemoes <

[PATCH 1/2] compiler.h: add support for function attribute assume_aligned

2015-10-02 Thread Rasmus Villemoes
gcc 4.9 added the function attribute assume_aligned, indicating to the caller that the returned pointer may be assumed to have a certain minimal alignment. This is useful if, for example, the return value is passed to memset(). Add a shorthand macro for that. Signed-off-by: Rasmus Villemoes <

[PATCH] lib/vsprintf.c: update documentation

2015-10-02 Thread Rasmus Villemoes
%n is no longer just ignored; it results in early return from vsnprintf. Also add a request to add test cases for future %p extensions. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- applies on top of lib-documentation-synchronize-%p-formatting-documentation.patch and it

[PATCH] kernel: time: timer.c: use __fls in apply_slack()

2015-10-02 Thread Rasmus Villemoes
1192106, but that is a false positive: Coverity is not aware that mask != 0 implies that find_last_bit will not return BITS_PER_LONG. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- kernel/time/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kerne

Re: [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask

2015-09-28 Thread Rasmus Villemoes
struct fadump_crash_info_header As preparation for eliminating the indirect access to the various global cpu_xyz_bits bitmaps via the pointer variables cpu_xyz_mask, rename the cpu_online_mask of struct fadump_crash_info_header to simply online_mask, to allow cpu_online_mask to become a macro. Signed-off-

Re: [PATCH 0/5] kernel/cpu.c: eliminate some indirection

2015-09-28 Thread Rasmus Villemoes
On Sun, Sep 27 2015, Rusty Russell wrote: > But to be clear, it has outlived its usefulness, but it was not useless. > > In particular, there used to be a debug config where 'struct cpumask' > wasn't defined, so we could catch people declaring 'struct cpumask' on > the

Re: [PATCH 1/3] Make /dev/urandom scalable

2015-09-30 Thread Rasmus Villemoes
On Thu, Sep 24 2015, Andi Kleen wrote: > > v2: Fix name of pool 0. Fix race with interrupts. Make > iteration loops slightly more efficient. Add ifdefs to avoid > any extra code on non-NUMA. Delay other pool use to when > the original pool initialized and initialize the

Re: [PATCH 5/5] selinux: use sprintf return value

2015-09-30 Thread Rasmus Villemoes
On Tue, Sep 29 2015, Stephen Smalley <s...@tycho.nsa.gov> wrote: > On 09/25/2015 06:34 PM, Rasmus Villemoes wrote: >> sprintf returns the number of characters printed (excluding '\0'), so >> we can use that and avoid duplicating the length computation. >> >> Si

[PATCH 1/2] regmap: debugfs: remove bogus check

2015-09-28 Thread Rasmus Villemoes
snprintf cannot return a negative value (unless map->dev->driver->name happens to be over 2G long). So remove the bogus check. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/base/regmap/regmap-debugfs.c | 4 1 file changed, 4 deletions(-) diff --git

[PATCH 2/2] regmap: debugfs: improve regmap_reg_ranges_read_file()

2015-09-28 Thread Rasmus Villemoes
snprintf is silly, when we know the length. Use memcpy instead. * Making the newline part of entry, we can avoid having to account for it separately in multiple places. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/base/regmap/regmap-debugfs.c | 19 +---

[PATCH v2 0/4] printf stuff

2015-09-30 Thread Rasmus Villemoes
://lkml.org/lkml/2015/9/16/769 Rasmus Villemoes (4): lib/vsprintf.c: handle invalid format specifiers more robustly lib/vsprintf.c: also improve sanity check in bstr_printf() lib/vsprintf.c: Remove SPECIAL handling in pointer() test_printf: test printf family at runtime lib/Kconfig.debug | 3

[PATCH v2 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer()

2015-09-30 Thread Rasmus Villemoes
structions. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- v2: reword slightly, refer to POSIX/C99. lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 03fa10b4be96..98b0d7be3fb7 100644 --- a/lib/vspr

[PATCH v2 2/4] lib/vsprintf.c: also improve sanity check in bstr_printf()

2015-09-30 Thread Rasmus Villemoes
intention all along. This is also the made-up value passed by sprintf and vsprintf. I should have seen this copy-pasted instance back then, but let's just do it now. Acked-by: Kees Cook <keesc...@chromium.org> Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- v2: add

[PATCH v2 1/4] lib/vsprintf.c: handle invalid format specifiers more robustly

2015-09-30 Thread Rasmus Villemoes
/arguments. If the offending specifier is in a printk() call we unfortunately only get a "BUG: recent printk recursion!", but at least direct users of the sprintf family will be caught. Reviewed-by: Andy Shevchenko <andriy.shevche...@linux.intel.com> Acked-by: Kees Cook <keesc...@chromi

[PATCH v2 4/4] test_printf: test printf family at runtime

2015-09-30 Thread Rasmus Villemoes
Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- v2: fix some cosmetic issues, avoid annoying gcc warning for empty format string, return success if and only if all tests passed, add reviewed-by. lib/Kconfig.debug | 3 + lib/Makefile | 1 + lib/test_pr

Re: [PATCH 4/4] test_printf: test printf family at runtime

2015-09-28 Thread Rasmus Villemoes
On Mon, Sep 28 2015, Andy Shevchenko <andriy.shevche...@linux.intel.com> wrote: > On Fri, 2015-09-25 at 19:41 +0200, Rasmus Villemoes wrote: >> This adds a simple module for testing the kernel's printf >> facilities. Previously, some %p extensions have caused a wrong re

Re: [PATCH 3/4] net: mv643xx_eth: use kzalloc

2015-09-09 Thread Rasmus Villemoes
On Wed, Sep 09 2015, Joe Perches <j...@perches.com> wrote: > On Wed, 2015-09-09 at 10:38 +0200, Rasmus Villemoes wrote: >> The double memset is a little ugly; using kzalloc avoids it altogether. > [] >> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c >>

Re: [PATCH] lib/vsprintf.c: increase the size of the field_width variable

2015-09-09 Thread Rasmus Villemoes
On Wed, Sep 09 2015, Joe Perches wrote: > On Wed, 2015-09-09 at 12:13 +0200, Maurizio Lombardi wrote: >> When printing a bitmap using the "%*pb[l]" printk format >> a 16 bit variable (field_width) is used to store the size of the bitmap. >> In some cases 16 bits are not

[PATCH] tracing: use kstrdup_const instead of private implementation

2015-09-09 Thread Rasmus Villemoes
(but non-const) array. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- kernel/trace/trace_events.c | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 7ca09cdc20c2..ae97d7

[PATCH] trace/ftrace.c: remove redundant swap function

2015-09-09 Thread Rasmus Villemoes
let sort() pick an appropriate and fast swap callback. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- kernel/trace/ftrace.c | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index b0623a

[PATCH] futex: eliminate cache miss from futex_hash()

2015-09-09 Thread Rasmus Villemoes
; : c3 retq : 0f 1f 00nopl (%rax) Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- Resending since this was never picked up - and I assume it's actually ok. Also, this time the alignment is spelled 2*sizeof(long) to avoid wasting 8 bytes

[PATCH] lib/dynamic_debug.c: use kstrdup_const

2015-09-09 Thread Rasmus Villemoes
Using kstrdup_const, thus reusing .rodata when possible, saves around 2 kB of runtime memory on my laptop/.config combination. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- lib/dynamic_debug.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git

[PATCH] PM / wakeup: wakeup_source_create: use kstrdup_const

2015-09-09 Thread Rasmus Villemoes
Using kstrdup_const allows us to save a little runtime memory (and a string copy) in the common case where name is a string literal. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/base/power/wakeup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

[PATCH 1/2] lib: introduce kvasprintf_const

2015-09-09 Thread Rasmus Villemoes
nstead use kstrdup_const directly (which would also require one to change all corresponding kfree calls to kfree_const). Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/kernel.h | 2 ++ lib/kasprintf.c| 16 2 files changed, 18 insertions(+) diff

[PATCH 2/2] kobject: use kvasprintf_const for formatting ->name

2015-09-09 Thread Rasmus Villemoes
MALLOC_SHIFT_LOW==5. Whether these numbers are sufficient to justify the ugliness I'll leave to others to decide. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- lib/kobject.c | 30 ++ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git

[PATCH 1/2] scsi: move Additional Sense Codes to separate file

2015-10-05 Thread Rasmus Villemoes
This is a purely mechanical move of the list of additional sense codes to a separate file, in preparation for reducing the impact of choosing CONFIG_SCSI_CONSTANTS=y by about 8k.. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/scsi/constants.c

[PATCH 2/2] scsi: reduce CONFIG_SCSI_CONSTANTS=y impact by 8k

2015-10-05 Thread Rasmus Villemoes
/shrink: 1/1 up/down: 24/-8488 (-8464) function old new delta scsi_extd_sense_format 136 160 +24 additional 113122824 -8488 Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes

[PATCH 0/2] scsi: reduce CONFIG_SCSI_CONSTANTS=y impact by 8k

2015-10-05 Thread Rasmus Villemoes
). Tested with a trivial module calling scsi_extd_sense_format with a few random known codes and comparing the result to the expected value. Rasmus Villemoes (2): scsi: move Additional Sense Codes to separate file scsi: reduce CONFIG_SCSI_CONSTANTS=y impact by 8k drivers/scsi/constants

Re: [PATCH] string: Improve the generic strlcpy() implementation

2015-10-05 Thread Rasmus Villemoes
On Mon, Oct 05 2015, Ingo Molnar wrote: > * Linus Torvalds wrote: > >> So I finally pulled it. I like the patch, I like the new interface, >> but despite that I wasn't really sure if I wanted to pull it in - thus >> the long delay of me just

Re: [PATCH 1/3] Make /dev/urandom scalable

2015-09-23 Thread Rasmus Villemoes
On Wed, Sep 23 2015, Andi Kleen wrote: > @@ -467,7 +478,7 @@ static struct entropy_store blocking_pool = { > > static struct entropy_store nonblocking_pool = { > .poolinfo = _table[1], > - .name = "nonblocking", > + .name = "nonblocking 0", > .pull =

Re: [PATCH] lib: Documentation: Synchronize %p formatting documentation

2015-09-22 Thread Rasmus Villemoes
On Mon, Sep 21 2015, Andy Shevchenko wrote: > On Mon, 2015-09-21 at 11:13 +0200, Martin Kletzander wrote: > >> Move all pointer-formatting documentation to one place instead of >> keeping it in three places with different level of completeness. I've had a

[PATCH 1/4] lib/vsprintf.c: handle invalid format specifiers more robustly

2015-09-25 Thread Rasmus Villemoes
/arguments. If the offending specifier is in a printk() call we unfortunately only get a "BUG: recent printk recursion!", but at least direct users of the sprintf family will be caught. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- lib/vsprintf.c | 31 +

[PATCH 2/4] lib/vsprintf.c: also improve sanity check in bstr_printf()

2015-09-25 Thread Rasmus Villemoes
intention all along. This is also the made-up value passed by sprintf and vsprintf. I should have seen this copy-pasted instance back then, but let's just do it now. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- lib/vsprintf.c | 2 +- 1 file changed, 1 insertio

[PATCH 0/4] printf stuff

2015-09-25 Thread Rasmus Villemoes
://lkml.org/lkml/2015/9/16/769 Rasmus Villemoes (4): lib/vsprintf.c: handle invalid format specifiers more robustly lib/vsprintf.c: also improve sanity check in bstr_printf() lib/vsprintf.c: Remove SPECIAL handling in pointer() test_printf: test printf family at runtime lib/Kconfig.debug | 3

[PATCH 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer()

2015-09-25 Thread Rasmus Villemoes
always 2*sizeof(void*), we can simplify the prologue of pointer() and save a few instructions. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 03fa10

[PATCH 4/4] test_printf: test printf family at runtime

2015-09-25 Thread Rasmus Villemoes
conventional table-driven approach. For now, this is mostly a skeleton; contributions are very welcome. Some tests are/will be slightly annoying to write, since the expected output depends on stuff like CONFIG_*, sizeof(long), runtime values etc. Signed-off-by: Rasmus Villemoes <

[PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask

2015-09-25 Thread Rasmus Villemoes
Replace the variables cpu_possible_mask, cpu_online_mask, cpu_present_mask and cpu_active_mask with macros expanding to expressions of the same type and value, eliminating some indirection. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/cpumask

[PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends

2015-09-25 Thread Rasmus Villemoes
indirection through the cpu_xyz_mask variables. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- kernel/cpu.c | 44 ++-- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 82cf9dff4295..fea4a3

[PATCH 3/5] drivers/base/cpu.c: use __cpu_*_mask directly

2015-09-25 Thread Rasmus Villemoes
-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- drivers/base/cpu.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 91bbb1959d8d..691eeea2f19a 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -200,7

[PATCH 2/5] kernel/cpu.c: export __cpu_*_mask

2015-09-25 Thread Rasmus Villemoes
Exporting the cpumasks __cpu_possible_mask and friends will allow us to remove the extra indirection through the cpu_*_mask variables. It will also allow the set_cpu_* functions to become static inlines, which will give a .text reduction. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes

[PATCH 0/5] kernel/cpu.c: eliminate some indirection

2015-09-25 Thread Rasmus Villemoes
, bloat-o-meter says we save ~3000 bytes. Rasmus Villemoes (5): kernel/cpu.c: change type of cpu_possible_bits and friends kernel/cpu.c: export __cpu_*_mask drivers/base/cpu.c: use __cpu_*_mask directly kernel/cpu.c: eliminate cpu_*_mask kernel/cpu.c: make set_cpu_* static inlines drivers

[PATCH 5/5] kernel/cpu.c: make set_cpu_* static inlines

2015-09-25 Thread Rasmus Villemoes
Almost all callers of the set_cpu_* functions pass an explicit true or false. Making them static inline thus replaces the function calls with a simple set_bit/clear_bit, saving some .text. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- include/linux/cpumask.

[PATCH 4/5] selinux: use kstrdup() in security_get_bools()

2015-09-25 Thread Rasmus Villemoes
This is much simpler. Signed-off-by: Rasmus Villemoes <li...@rasmusvillemoes.dk> --- security/selinux/ss/services.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index 994c824a34c6..aa2bdcb20848

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