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: <2f966e28-cebd-067d-580e-ad6a1fc32c35@kernel.org>
Date:   Tue, 28 Jun 2022 16:46:44 -0700
From:   Andy Lutomirski <luto@...nel.org>
To:     Fanjun Kong <fanjun.kong@...ux.dev>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>
Cc:     Muchun Song <songmuchun@...edance.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/mm: declare static variable inside a function instead
 of global

On 6/18/22 03:11, Fanjun Kong wrote:
> Global variables are global capacity variables, unless they are
> shadowed, they are available to the entire program.

This is true in general, but:

> -static unsigned long memory_block_size_probed;

    ^^^^^^

So this isn't actually the case.

>   unsigned long memory_block_size_bytes(void)
>   {
> +	static unsigned long memory_block_size_probed;
> +
>   	if (!memory_block_size_probed)
>   		memory_block_size_probed = probe_memory_block_size();
>   

I'm sort of okay with the patch, but it's worth noting that, in C++, 
initialized function-scope static variables have quite surprising 
semantics, so this type of change isn't a pure win in my book.  (Yes, 
the kernel is C, not C++.  But C++ programmers may be nervous anyway.)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ