Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2420953pxb; Tue, 12 Oct 2021 06:20:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCPry9a2LXSjbUkW+c3ClWt2YRdtHYQtBnuxgXrfm2Nv3HoZ41bcMRhfiSIdkE9kHv7SfF X-Received: by 2002:a17:902:e846:b0:13f:551b:ba23 with SMTP id t6-20020a170902e84600b0013f551bba23mr2652627plg.77.1634044833918; Tue, 12 Oct 2021 06:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634044833; cv=none; d=google.com; s=arc-20160816; b=R6V0EJl+cleuzlLaixqxmU0NHMLoDertAJq8l7zFlByCYOgipBY+KNO1VFfOrGaoyg eVW0ASEnZNDJkOvEGHpTZPouXC10+b9fwBw82lRXu/YDxbIFFQSLwXY9iLhQaf9stymy gtNZX84rsVlCzsLSTEu0yvBbyOUJvENu9mo//fhWFz5EpmanPYKa6Y7vb1IJDdaczSm0 K7ym52twSnj31uuiO2P8geuGPVFZl90+FPhUEf0LkdTq6rYrF1wgxKksFUFrUJ97Twfu 8tQeLjiODhR4iFiOubbr6nC0ihBwpDomrXuPk6YihPPe4c2Qfer5A/aGz78B3GcmydtC xWBQ== 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=PcrwjpNbjvSiMmJst3jkPTToJXQ7Gee1/ZPXz0Rsz7M=; b=oz912vr5+d8IjUgU1Nn9/Whp5SNGseKxQ5I0TDs/a2eepXO9r+LtCu8rinuHK0NonZ VHXehQyZkaRN0Us/M8Nn14TSRjoAmfZVSGcNvY/OzEWqP7kJr/orP3TYPy6xwNFGpNGb rH2cgJZsZWJUyYYuejjd6b8nizsQ/7WVafrwlSm55iOzvuDslt8mkSW57tfqFMyIx6FX ZHzqyPetZabQtmTqW/J9phBSTwzQxzLkHb1aByHF8oM8bGQIuwp62I2MkB3ZqzB7BiKL DspInSy1wHKAywAnx00TQ5eVv3+MIbpsV+uTn9H2yqJ1HocmnpUZyNjecTG2xJp9nbP0 7xZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GA7Ap1p4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si1129068plg.32.2021.10.12.06.20.19; Tue, 12 Oct 2021 06:20:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=GA7Ap1p4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236608AbhJLNTr (ORCPT + 99 others); Tue, 12 Oct 2021 09:19:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236544AbhJLNTq (ORCPT ); Tue, 12 Oct 2021 09:19:46 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48012C061570 for ; Tue, 12 Oct 2021 06:17:39 -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=PcrwjpNbjvSiMmJst3jkPTToJXQ7Gee1/ZPXz0Rsz7M=; b=GA7Ap1p4PUzee/noDlsPlNNt3g oOGOpEFxde0qrjAZ/i7tC6jiDh7Cq+O+VJdgYKg3XWFcuZBMz2rdBPT9X7CwSQ6UMvXL1bduhgUi6 JNL8/SNW2ej3vXXAZPOwFAsDiRq//i7Mcrip0JlgwWDc6gF4IaxaFCYMmgn34lgO3Z/uGOsSao43z JRpvIYmIcn3HW8OhN10bSw/5hX/Pv4qvcheb8mog5gvPBsdvehiY4DKlBER23XDv7fqTtQkdPGHZT McB6HvEb8foCPDbkyMebzM0eJDnliiSBxTE2Z/IUC0CJs/EsaNMAjDdpqG2z32vbarZkE+1IvgQBw 9H5IfO0A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1maHdG-006WfH-Nn; Tue, 12 Oct 2021 13:16:05 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 7384230030B; Tue, 12 Oct 2021 15:15:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 578722C10165C; Tue, 12 Oct 2021 15:15:50 +0200 (CEST) Date: Tue, 12 Oct 2021 15:15:50 +0200 From: Peter Zijlstra To: Yanfei Xu Cc: mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] locking/mutex: remove rcu_read_lock/unlock as we already disabled preemption Message-ID: References: <20211008032518.1298372-1-yanfei.xu@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211008032518.1298372-1-yanfei.xu@windriver.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 08, 2021 at 11:25:18AM +0800, Yanfei Xu wrote: > preempt_disable/enable() is equal to RCU read-side crital section, > and the mutex lock slowpath disabled the preemption for the optimistic > spinning code. Let's remove the rcu_read_lock/unlock for saving some > cycles in hot codes. > > Signed-off-by: Yanfei Xu > --- > v1->v2: fix the incorrect comment in code and commit message. > thanks for WaiMan's suggestion. > > BTW, sorry for this late v2 due to a long vocation. > > kernel/locking/mutex.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c > index 2fede72b6af5..2f654cfb10d9 100644 > --- a/kernel/locking/mutex.c > +++ b/kernel/locking/mutex.c > @@ -351,13 +351,14 @@ bool mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner, > { > bool ret = true; lockdep_assert_preemption_disabled(); > - rcu_read_lock(); > while (__mutex_owner(lock) == owner) { > /* > * Ensure we emit the owner->on_cpu, dereference _after_ And did you check the other code in locking/ for similar things?