From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753023AbdKIHuU (ORCPT ); Thu, 9 Nov 2017 02:50:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:48975 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752732AbdKIHuS (ORCPT ); Thu, 9 Nov 2017 02:50:18 -0500 Date: Thu, 9 Nov 2017 08:50:16 +0100 From: Michal Hocko To: Kees Cook Cc: Vlastimil Babka , Andrew Morton , Jesper Dangaard Brouer , Dave Hansen , Ying Huang , LKML Subject: Re: [PATCH] mm, vmstat: Make sure mutex is a global static Message-ID: <20171109075016.ufgjvegqghjus3wc@dhcp22.suse.cz> References: <20171107213809.GA4314@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 08-11-17 07:21:20, Kees Cook wrote: > On Tue, Nov 7, 2017 at 11:43 PM, Vlastimil Babka wrote: > > On 11/07/2017 10:38 PM, Kees Cook wrote: [...] > >> +static DEFINE_MUTEX(vm_numa_stat_lock); > >> + > >> int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, > >> void __user *buffer, size_t *length, loff_t *ppos) > >> { > >> int ret, oldval; > >> - DEFINE_MUTEX(vm_numa_stat_lock); > > > > Yeah it was Michal who suggested scoping the mutex here instead of > > global scope, but I think he didn't mean to remove the 'static' > > qualifier, and we both missed that in the review :( > > So the scope under sysctl_vm_numa_stat_handler() should be okay, just > > with the 'static' added. > > That part is a matter of taste, I guess. :) But yes, static is important. The primary reason I prefer function scope lock is that it is less tempting to reuse the lock for something else that way. But this is hardly something to insist on. So I am ok with the file scope as well. -- Michal Hocko SUSE Labs