Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4730839iob; Sun, 8 May 2022 23:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIG0A00B87Gx6ZjEtToSdKGk1l7dnkYk6SYo5n2lxCQ/tVuYUCYlnbpprcNTEM1jd4YLP6 X-Received: by 2002:a17:902:ecc2:b0:15e:9add:104c with SMTP id a2-20020a170902ecc200b0015e9add104cmr15051141plh.140.1652078016774; Sun, 08 May 2022 23:33:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652078016; cv=none; d=google.com; s=arc-20160816; b=xhgLRC52iWtvH6TxrkLB8l5LdK0Qoc+9Lti0r7VSN/QeAkve7yIwMM8HbQxWli4wBq HcvDYaJQRX9VrIyfKm5uEcCZoemJSAE6gRcmP1sIKpT3JvndiyJWUDp1glnULe3cAVum SK5PYm4yo3lGsWSQeua2ITM9b5Diwk/hrxkhnjHYLYC15At5TjbdetUZRkZTDJmBG3IS 9DjhhSH/ZDZ5sCX0vJwPXYvAlGqbiE80HsKHWNa+epAIo9EcmsqxJEoD8WWa2c0QFJ/9 6wJF3W3bCmN7Bha7Np+iy5Z8ql4HnFXlhGe2lk9iW3Gou3PTm2Q/W9wSX7zJq22mzAVq pkPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kPqUPzB7ZQQlCv5tpljxbIPbLYmA0so+DR2l5Jk0zMg=; b=Vn/+V90EJaEtHOccYiGph9Q5Z1nVZIAyeFbVIvTFtt6j5ZjA+fPggIQzI12lNSMEyA bs8FBlxu80MJ1iM7+EBiN2ikpkyLCNruuA9em1qD9Y5FjZ8PrdVcqV2mAalwQBTttkrn r6ZxDmmi+UtspSuQU/d8b6LVowl25sk2fdTMpfjTyrhCqFW+CK7O3B9bemgBq6ZYpP8l DtwcOrkwEHTgmG/YtL6JfYyfcjB1wdZJ47yKn/BmdLUK7FAudEmE8xVG8SKiALb0DZeO 3EqPvz8Qa+S9qANSvJdys2k+Q9DElfODwTJKFS+2ChqRP60Jvy0Yrk0JzpJyjNXWE7n0 O7dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fVfdadQ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e7-20020a656bc7000000b00382274f6ae9si8487160pgw.589.2022.05.08.23.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:33:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fVfdadQ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED66C18B106; Sun, 8 May 2022 23:30:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242617AbiEEEQr (ORCPT + 99 others); Thu, 5 May 2022 00:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbiEEEQp (ORCPT ); Thu, 5 May 2022 00:16:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91A7A1C93C for ; Wed, 4 May 2022 21:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kPqUPzB7ZQQlCv5tpljxbIPbLYmA0so+DR2l5Jk0zMg=; b=fVfdadQ5Pr5sgP2TEYrIde1mLD G6BG/RwDPOqG/wYBd0imGWBVIUtRwNbe5ecX30qffFSkiFMkt3iQxbpF89w5f/jbfDS6jgW67b2Im u0Qtnu+aTCO7NJfi8XxBxI9dr7+tZc6T58HIg+LsTweEFdRiIe8kYGkQsWG9q5W7Goj+D6riJhURa PmtCey6AvB8S7CMaZ8bHjU1+M9qFsUG3ScJo+4qWrDEBLRyYvhZfMJSHj6X2BybPfL52iCLs9BC3F 5eqGF4GaOyDI2nYMp5I7TWVGjJUIVAenWRpYO3S3dIB4QiRH635YmScSKo62jDyTgrR+D6mM8xES8 zhKGZiAg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmSr4-00HFa4-KT; Thu, 05 May 2022 04:12:42 +0000 Date: Thu, 5 May 2022 05:12:42 +0100 From: Matthew Wilcox To: Hillf Danton Cc: Waiman Long , "Paul E. McKenney" , "Liam R. Howlett" , linux-kernel@vger.kernel.org Subject: Re: Wait for mutex to become unlocked Message-ID: References: <20220505015223.5132-1-hdanton@sina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220505015223.5132-1-hdanton@sina.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 05, 2022 at 09:52:23AM +0800, Hillf Danton wrote: > +++ x/kernel/locking/rwsem.c > @@ -1464,6 +1464,35 @@ void __sched down_read(struct rw_semapho > } > EXPORT_SYMBOL(down_read); > > +static void __rwsem_wait(struct rw_semaphore *sem, int read, int state) > +{ > + DEFINE_WAIT(wait); > + int locked; > + > + prepare_to_wait(&sem->willy_wq, &wait, state); > + if (read) > + locked = down_read_trylock(sem); ... but then we just acquired the lock. And the point was to never acquire the lock. Also, what's the 'willy_wq' thing? Do you mean wait_list? Oh, no, I see, you're pretending that we should add an extra waitq to the rwsem. That's very silly. The point was not to ask "how can we do this", the question was "should we do this?" And Thomas, at least for now, is saying "No". If you want to figure out how to do it properly, see rwsem_add_waiter() and how it's used.