Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp358092imu; Mon, 10 Dec 2018 23:40:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wc+gGpsBv56twz+uKYLzEpdor+XwMNC/vsQ4EjP4IQEpiwndCSHeGddmcHPZ8ecRM7uMTW X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr14681803plh.99.1544514011460; Mon, 10 Dec 2018 23:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544514011; cv=none; d=google.com; s=arc-20160816; b=c0QBJDqRk8mCJ/BjFsqdFWI3q4IAVYZ5A7tevl4KNKMVtY7/K67kjlUKvM5GeoH66/ EhHSopcMx4Qa700z3VqbdkMvK6zy/oLeh6DXFnxF+YyL7xX/JWkPh4NI80vyctlsXKcC aCL0mCw86togqWsewUG0u1Utbvk1ZzDzD5j1XAzzvS0Raxs/dCsQ6M7Ks0d9iUTi0PGE LUog803dFlMxXg9IczN3jNnxFpT/xN99knezxMmJXhKZvEIiJCp/xdnhHDzrPnhGQXUK mjKx9RQKAbACdW6L4+y9RR2cAi4HineMUU6ZoE5SUDyjAVop3Zo4umKKUxuZczf9uAIq LgBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date; bh=2TpO/ncRDUZOoYi2S0TXqD2iDOosY30d5K4Y0LxXjTc=; b=BCmsWZLINPhvXxp1fDU7J3iVTj/xL72hDQdP8Me2qX99szaoceukE4tZUJHueZeRXQ UV4Shwk//5sMeMgn/7yyXJ5hQg36AmOEI8+LOrb1/vFT80u6pWVyDC5u/E3GNiE6XteF GoxMa6NX+Omjs74egPEc6Ou/n197Z2Q+1rpZ+3bJqjup/UALrJ+01jfkmirg2buDUrav lUz81Xd3yfqmO5vTtahI1rdml7IJREeXoSg2OiEWxJ8VLpxsxwDTwLdTHTGvWqfPtNFh 6xQlRyBDAzsEhe8Lne4LxyyWMuDJrHTR0WCA2jzPpVBRYbEJ0JdN3hwKUqD88rn/C054 SipQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u184si11561635pgd.262.2018.12.10.23.39.55; Mon, 10 Dec 2018 23:40:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726164AbeLKHij (ORCPT + 99 others); Tue, 11 Dec 2018 02:38:39 -0500 Received: from orbyte.nwl.cc ([151.80.46.58]:51158 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbeLKHij (ORCPT ); Tue, 11 Dec 2018 02:38:39 -0500 Received: from n0-1 by orbyte.nwl.cc with local (Exim 4.91) (envelope-from ) id 1gWccb-00061P-5i; Tue, 11 Dec 2018 08:38:25 +0100 Date: Tue, 11 Dec 2018 08:38:25 +0100 From: Phil Sutter To: Herbert Xu Cc: Arnd Bergmann , Thomas Graf , "David S. Miller" , NeilBrown , Tom Herbert , Kees Cook , Paul Blakey , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] test_rhashtable: remove semaphore usage Message-ID: <20181211073825.GT30790@orbyte.nwl.cc> Mail-Followup-To: Phil Sutter , Herbert Xu , Arnd Bergmann , Thomas Graf , "David S. Miller" , NeilBrown , Tom Herbert , Kees Cook , Paul Blakey , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20181210211957.210189-1-arnd@arndb.de> <20181211054552.peone47xl5czpfar@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181211054552.peone47xl5czpfar@gondor.apana.org.au> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Dec 11, 2018 at 01:45:52PM +0800, Herbert Xu wrote: > On Mon, Dec 10, 2018 at 10:17:20PM +0100, Arnd Bergmann wrote: > > This is one of only two files that initialize a semaphore to a negative > > value. We don't really need the two semaphores here at all, but can do > > the same thing in more conventional and more effient way, by using a > > single waitqueue and an atomic thread counter. > > > > This gets us a little bit closer to eliminating classic semaphores from > > the kernel. It also fixes a corner case where we fail to continue after > > one of the threads fails to start up. > > > > An alternative would be to use a split kthread_create()+wake_up_process() > > and completely eliminate the separate synchronization. > > > > Signed-off-by: Arnd Bergmann > > --- > > This is part of a longer, untested, series to remove semaphores > > from the kernel, please review as such before applying. > > --- > > lib/test_rhashtable.c | 28 ++++++++++++++++------------ > > 1 file changed, 16 insertions(+), 12 deletions(-) > > This was created by Phil Sutter so I am adding him to the cc list. Thanks, I would have missed it otherwise. Just a minor nit: > > diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c > > index 18de5ff1255b..12bdea4f6c20 100644 > > --- a/lib/test_rhashtable.c > > +++ b/lib/test_rhashtable.c [...] > > @@ -635,8 +636,9 @@ static int threadfunc(void *data) > > int i, step, err = 0, insert_retries = 0; > > struct thread_data *tdata = data; > > > > - up(&prestart_sem); > > - if (down_interruptible(&startup_sem)) > > + if (atomic_dec_and_test(&startup_count)) > > + wake_up(&startup_wait); > > + if (wait_event_interruptible(startup_wait, atomic_read(&startup_count) == -1)) > > pr_err(" thread[%d]: down_interruptible failed\n", tdata->id); The error message should probably be adjusted as well. Apart from that: Acked-by: Phil Sutter Thanks, Phil