From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f196.google.com ([209.85.215.196]:45395 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbeGREMV (ORCPT ); Wed, 18 Jul 2018 00:12:21 -0400 Received: by mail-pg1-f196.google.com with SMTP id f1-v6so1333798pgq.12 for ; Tue, 17 Jul 2018 20:36:36 -0700 (PDT) Date: Tue, 17 Jul 2018 20:36:34 -0700 From: Omar Sandoval To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexey Dobriyan , Eric Biederman , James Morse , Bhupesh Sharma , kernel-team@fb.com Subject: Re: [PATCH v2 2/7] proc/kcore: replace kclist_lock rwlock with rwsem Message-ID: <20180718033634.GD29351@vader> References: <783ba3becc424db45e5d5c93559fc40ef6173f01.1531440458.git.osandov@fb.com> <20180717193841.271d1c57b6f88d75c83892be@linux-foundation.org> <20180718032405.GB29351@vader> <20180717202753.d49795afde465d04b56efbfb@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180717202753.d49795afde465d04b56efbfb@linux-foundation.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Jul 17, 2018 at 08:27:53PM -0700, Andrew Morton wrote: > On Tue, 17 Jul 2018 20:24:05 -0700 Omar Sandoval wrote: > > > > > --- a/fs/proc/kcore.c > > > > +++ b/fs/proc/kcore.c > > > > @@ -59,8 +59,8 @@ struct memelfnote > > > > }; > > > > > > > > static LIST_HEAD(kclist_head); > > > > -static DEFINE_RWLOCK(kclist_lock); > > > > -static int kcore_need_update = 1; > > > > +static DECLARE_RWSEM(kclist_lock); > > > > +static atomic_t kcore_need_update = ATOMIC_INIT(1); > > > > > > It's unclear why kcore_need_update was changed to atomic_t - it's still > > > updated under kclist_lock? > > > > Not in the hotplug notifier (kcore_callback()) anymore, so I need the > > atomic_cmpxchg() in __kcore_update_ram(). > > Well that's just > > kcore_need_update = 1; > > and turning that into an atomic_set doesn't change anything(?). > > It's not a harmful change of course, but a bit ... odd. The change from read, ..., write to cmpxchg in __kcore_update_ram() is the important part, not the change from = to atomic_set(). I needed to change that because now kcore_need_update could potentially be set again by the hotplug notifier while we're in __kcore_update_ram(). But I'll just put all of this in the commit message in v3 :) > > That could use a mention in the commit message. > > That never hurts ;)