Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp254938imu; Mon, 10 Dec 2018 21:04:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/WtuXIPaqpmZEJLKVAW0T+W3aaCEbl/doRBuTM0nhsOcJMHcQ7dPiH1Uh7SrWWsiYY1CZ9s X-Received: by 2002:a63:3d03:: with SMTP id k3mr13377261pga.191.1544504692211; Mon, 10 Dec 2018 21:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544504692; cv=none; d=google.com; s=arc-20160816; b=yd2iLVMOZxT3kxucXha+qSyKouA7fxZj5k6B1+pT+ltNnvReiPyxH9SE6UxSmoY05u OY7F/Lnn1HGF0v9J6kTXqLfejW8aTnfse6kMLh+JG/jp5fe8RSndytusrOKlhz0TqjDo /H5abn88/4riQVjzNAlV0Cn6q6pGs9Xo7m/kBI+C2c1CNg7423aTzk/Es+/46zUL11Xu DjxRwjp8XSuB2We6e+/NiPUTYAeiSlbGlx1tUWFWdpFUKmwlWzbWIH9KwPG032aFfmCw MAZ/LECj1sB7aYUlkD9BBNUWTc+4W5OKLXFHdmkN2656ojjDzLfEOuoxwpnLlSum1aYT 9ccg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=xmd+IbSi8VN7iVMzmeC8ram4aMjd2FizlDwecWQO5wk=; b=XVYGrFl1rPSzwwtEcnDCVBTaWi83Dz3GbwYmKNDmV6e0SacdqkYRHf9q416DNoqmsI gc0CHlbIGykcSCxs7cH+ca5rWbhd6OqdzlfO8T9R+ME5rlIvpCv/nz/mOtXSBUnK4fVt ZSsfvwiZH7CCZqU7HI/zIAtN/8+Ite26/ViLxhxuvNXRRtL6B96DCABbI+bW1cYjfMxZ lou4aftbGVnMgSEJTnhB/FNkx23BOamSDYIfzL3ZV/RT4t3Fgvj9czawzU+hEhhTpIlK +Q2MCnVA4qZCVKubHiadlyE2PPczKw8n/29fyIO+a0zaUbc0LvwxXboEa5DbaWelNFqW tXFA== 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 t2si6180480plz.344.2018.12.10.21.04.36; Mon, 10 Dec 2018 21:04:52 -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 S1728755AbeLKB3O (ORCPT + 99 others); Mon, 10 Dec 2018 20:29:14 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:49920 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727276AbeLKB3N (ORCPT ); Mon, 10 Dec 2018 20:29:13 -0500 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::bf5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id CE897100AAA08; Mon, 10 Dec 2018 17:29:12 -0800 (PST) Date: Mon, 10 Dec 2018 17:29:12 -0800 (PST) Message-Id: <20181210.172912.1960183648027850219.davem@davemloft.net> To: arnd@arndb.de Cc: tgraf@suug.ch, herbert@gondor.apana.org.au, neilb@suse.com, tom@quantonium.net, keescook@chromium.org, paulb@mellanox.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] test_rhashtable: remove semaphore usage From: David Miller In-Reply-To: <20181210211957.210189-1-arnd@arndb.de> References: <20181210211957.210189-1-arnd@arndb.de> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 10 Dec 2018 17:29:13 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann Date: Mon, 10 Dec 2018 22:17:20 +0100 > 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. This looks fine to me, although it seems kinda weird how the synchronization works in that the N - 1 child threads will be awoken two times, once when child N decrements the count to zero and once when the parent decrements the count to -1 which lets us past the wait_event_interruptibel(). Nevertheless it should work just fine and I have no problems with it. Want me to apply this to net-next? Thanks.