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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 17 Oct 2017 09:54:20 +0200
From:   Michal Hocko <mhocko@...nel.org>
To:     Kemi Wang <kemi.wang@...el.com>
Cc:     "Luis R . Rodriguez" <mcgrof@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Jonathan Corbet <corbet@....net>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Johannes Weiner <hannes@...xchg.org>,
        Christopher Lameter <cl@...ux.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Vlastimil Babka <vbabka@...e.cz>,
        Andrey Ryabinin <aryabinin@...tuozzo.com>,
        Dave <dave.hansen@...ux.intel.com>,
        Tim Chen <tim.c.chen@...el.com>,
        Andi Kleen <andi.kleen@...el.com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Ying Huang <ying.huang@...el.com>,
        Aaron Lu <aaron.lu@...el.com>,
        Proc sysctl <linux-fsdevel@...r.kernel.org>,
        Linux MM <linux-mm@...ck.org>,
        Linux Kernel <linux-kernel@...r.kernel.org>,
        Linux API <linux-api@...r.kernel.org>
Subject: Re: [PATCH v4] mm, sysctl: make NUMA stats configurable

On Tue 17-10-17 09:20:58, Kemi Wang wrote:
[...]

Other than two remarks below, it looks good to me and it also looks
simpler.

> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 4bb13e7..e746ed1 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -32,6 +32,76 @@
>  
>  #define NUMA_STATS_THRESHOLD (U16_MAX - 2)
>  
> +#ifdef CONFIG_NUMA
> +int sysctl_vm_numa_stat = ENABLE_NUMA_STAT;
> +static DEFINE_MUTEX(vm_numa_stat_lock);

You can scope this mutex to the sysctl handler function

> +int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write,
> +		void __user *buffer, size_t *length, loff_t *ppos)
> +{
> +	int ret, oldval;
> +
> +	mutex_lock(&vm_numa_stat_lock);
> +	if (write)
> +		oldval = sysctl_vm_numa_stat;
> +	ret = proc_dointvec(table, write, buffer, length, ppos);
> +	if (ret || !write)
> +		goto out;
> +
> +	if (oldval == sysctl_vm_numa_stat)
> +		goto out;
> +	else if (oldval == DISABLE_NUMA_STAT) {

So basically any value will enable numa stats. This means that we would
never be able to extend this interface to e.g. auto mode (say value 2).
I guess you meant to check sysctl_vm_numa_stat == ENABLE_NUMA_STAT?

> +		static_branch_enable(&vm_numa_stat_key);
> +		pr_info("enable numa statistics\n");
> +	} else if (sysctl_vm_numa_stat == DISABLE_NUMA_STAT) {
> +		static_branch_disable(&vm_numa_stat_key);
> +		invalid_numa_statistics();
> +		pr_info("disable numa statistics, and clear numa counters\n");
> +	}
> +
> +out:
> +	mutex_unlock(&vm_numa_stat_lock);
> +	return ret;
> +}
> +#endif
> +
>  #ifdef CONFIG_VM_EVENT_COUNTERS
>  DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
>  EXPORT_PER_CPU_SYMBOL(vm_event_states);
> -- 
> 2.7.4
> 

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ