Re: [PATCH] sysctl: add register_sysctl() dummy helper
From: Arnd Bergmann
Date: Mon Nov 06 2017 - 12:12:11 EST
On Mon, Nov 6, 2017 at 5:50 PM, Dave Martin <Dave.Martin@xxxxxxx> wrote:
> On Mon, Nov 06, 2017 at 01:36:40PM +0000, Arnd Bergmann wrote:
>> The register_sysctl() function has been around for five years with commit
>> fea478d4101a ("sysctl: Add register_sysctl for normal sysctl users")
>> but now that arm64 started using it, I ran into a compile error:
>>
>> arch/arm64/kernel/armv8_deprecated.c: In function 'register_insn_emulation_sysctl':
>> arch/arm64/kernel/armv8_deprecated.c:257:2: error: implicit declaration of function 'register_sysctl'
>
> Hmmm, looks like I missed this combination in testing.
>
> I wonder whether ARMV8_DEPRECATED without SYSCTL is really a good idea
> though: in that config, we build a lot of dead code and leak some
> memory today. The default emulation is still potentially useful, but
> all the support for runtime twiddling of the emulation modes becomes
> useless.
>
> For parallel reasons, the SVE sysctl stuff is protected by #ifdef
> CONFIG_SYSCTL, which is why I didn't get a similar splat there.
>
>
> So, although this patch is superficially sensible, it may tend to hide
> bugs: code that calls register_sysctl() when CONFIG_SYSCTL=n is
> suspicious and probably needs review... no?
I think your analysis for this code is correct, we waste a lot of memory
if we do it like this. However in the general case where we register a
statically allocated 'struct ctl_table', it wouldn't be an issue, because
gcc could then eliminate all the dead code.
Adding a CONFIG_SYSCTL #ifdef or Kconfig dependency would
probably be reasonable for armv8_deprecated.c, for the rest of
the kernel, having that wrapper is probably better.
I don't really care how this gets fixed, as long as some solution gets
merged.
Arnd