Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp207373lqe; Fri, 5 Apr 2024 19:40:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0cZDMc5xwe8RIYTrEx63TjjjHJEiykZG/joi8Vgo7cqqT36ohQ6KjAvEX0g8k4iWPOXPkPPtblpVaQku9cUbNiPDczDA4r9qEyj+jwA== X-Google-Smtp-Source: AGHT+IGbyqtMjSYViiwYQS+ZdWs2Fwgw7bzT3nMvoSF77cFrHzkcri8/l75dGY2F0XInuIwltSK/ X-Received: by 2002:a05:620a:7ee:b0:789:f51a:ace0 with SMTP id k14-20020a05620a07ee00b00789f51aace0mr3084573qkk.63.1712371209777; Fri, 05 Apr 2024 19:40:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712371209; cv=pass; d=google.com; s=arc-20160816; b=ecdG9AH89BDZhjhi8MGzhiZkpNpdKmWeICQwO8Ls7+VFtS1Onim14vOgum8xhfFWVN CLr34v6gY0XL1g3QEfrfB2D//lXLsjPKr81V2T/gSeJ7C/ZvmmW/SMpEYssEyPgNXwrs BybTaYE/8iUgI0HVKaqwnykeceb8oRy7bGPvB3INOpHxe9YzNiKDj3ZEi2DnXZFqqvjO O7AnHZi5BZCCUT9cf9fSVSbWZAunZudAWg8tzIY/fhL5B7UIfsSH6wZ2+cBmnd48nmaU 7wE2EHWhTdZVUkETV2NiI3VCpL1fsqlgSxg/4rX0Ko3sWbuoCjSJxSQsDwU+75b1nYUP JtoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=fhyMJE+ElOP3Y8M4yz3wVNLcPBnn/sRAIecaPUAaVLE=; fh=Gnq/ii7OX1VtS+ZNI9ZGdJsd8vQXmxpEFtAgBJZckJQ=; b=EuZq3fXCGpXpiHtHiuDvTiOOxQTsZP7leFkF4TC9mlsmJGmdYVvc+f6g+F9ZINaqAk JSRzOdn4Ddy1WYqmX7uh4q0X3LWgYkjwXBXhOkcni+wPKGAqcKnlBmbroyJIjVht09Dz RJaG77STz7KXFMgx2eIor1OkVNmTDOCzbTqb2idlb6bw0lWdr20r4vzX+4bWnx6tMwhi tLSUDKxycZ+KFh02Yw4eUGLRqQWGvftkxYUjC8l5hT0sFBp5ctW3msNtVigipOSQeTxr VY37MTFW4sVLBYwv8I6/cdStVGjdpML0kCr66OdCZYvL7YYgGpD3j3cKFYqCzyc/Pb+q VljA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="d3KC/a7V"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-133775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j19-20020a05620a147300b00789e6ace0basi3164484qkl.408.2024.04.05.19.40.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 19:40:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="d3KC/a7V"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-133775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7CCA81C20DB8 for ; Sat, 6 Apr 2024 02:40:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5618B12B89; Sat, 6 Apr 2024 02:40:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d3KC/a7V" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97CB8C8E1 for ; Sat, 6 Apr 2024 02:40:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712371202; cv=none; b=gttU3oS4JC21kCY40KWaT9+D41Cpjfn6TB1Kg3bDuJBXASL5J8dRpJM8T+c5a0bzW46LMk6R7gGtYZcFmrHtb9eco31jCgbZhWbo1oAD4lS62PcT9QYcHPa8GhEb/WONuCG6lMYno2HSE3nJgOSjRPdrpi1PSnidoMjdw1ppY1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712371202; c=relaxed/simple; bh=sO2EQQtfCTdFd4jXvSDM2x+7AjI/KHqqPxsujAmIuGg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Zs84QXTNwoy1EHLbShYAhkLyZXBoW3dQeyDZjJzoIBQET0vjWbmnqa/kg5gfn7WCXWIKKwqWoZkij3+pYNUmV1mX7LtUsdyKwSghCCPHcScslkAzGyMPvQG3BaxTQMcaQL/qNzb4/kxd6G+lmApyCsYEUG4xliV7w18wwMqfnSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=d3KC/a7V; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712371199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fhyMJE+ElOP3Y8M4yz3wVNLcPBnn/sRAIecaPUAaVLE=; b=d3KC/a7VHAIoix8xnF61o/UGMcu4aS5DU61045BEguOjqVAn2026kKIA9ErRCdwQNSBmsg C5EQNUIrt7Mi9ioFDyQd/UlhMswsIg01zyu0kFfWyfeYcXmOjoRdOsh7lxDbqp1zWOquHz LFFwT3ksJEOKzXfELYlVP7k+cwXJoSU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-166-oHgtdRbfNxuBy6vv9oRanA-1; Fri, 05 Apr 2024 22:39:56 -0400 X-MC-Unique: oHgtdRbfNxuBy6vv9oRanA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 23DE380B1E0; Sat, 6 Apr 2024 02:39:56 +0000 (UTC) Received: from [10.22.10.118] (unknown [10.22.10.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5E1940C6CB3; Sat, 6 Apr 2024 02:39:55 +0000 (UTC) Message-ID: <221c28a1-cb61-4a8f-96b5-d9407e53d759@redhat.com> Date: Fri, 5 Apr 2024 22:39:55 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC][PATCH] locking/rwsem: Add __always_inline annotation to __down_write_common() and inlined callers Content-Language: en-US To: John Stultz , LKML Cc: Tim Murray , Nick Desaulniers , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , kernel-team@android.com References: <20240405200535.2239155-1-jstultz@google.com> From: Waiman Long In-Reply-To: <20240405200535.2239155-1-jstultz@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 On 4/5/24 16:05, John Stultz wrote: > Apparently despite it being marked inline, the compiler > may not inline __down_write_common() which makes it difficult > to identify the cause of lock contention, as the blocked > function in traceevents will always be listed as > __down_write_common(). > > So add __always_inline annotation to the common function (as > well as the inlined helper callers) to force it to be inlined > so the blocking function will be listed (via Wchan) in > traceevents. > > This mirrors commit 92cc5d00a431 ("locking/rwsem: Add > __always_inline annotation to __down_read_common() and inlined > callers") which did the same for __down_read_common. > > I sort of worry that I'm playing wack-a-mole here, and talking > with compiler people, they tell me inline means nothing, which > makes me want to cry a little. So I'm wondering if we need to > replace all the inlines with __always_inline, or remove them > because either we mean something by it, or not. > > Cc: Tim Murray > Cc: Nick Desaulniers > Cc: Peter Zijlstra > Cc: Ingo Molnar > Cc: Will Deacon > Cc: Waiman Long > Cc: Boqun Feng > Cc: kernel-team@android.com > Fixes: c995e638ccbb ("locking/rwsem: Fold __down_{read,write}*()") > Reported-by: Tim Murray > Signed-off-by: John Stultz > --- > kernel/locking/rwsem.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c > index c6d17aee4209..33cac79e3994 100644 > --- a/kernel/locking/rwsem.c > +++ b/kernel/locking/rwsem.c > @@ -1297,7 +1297,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem) > /* > * lock for writing > */ > -static inline int __down_write_common(struct rw_semaphore *sem, int state) > +static __always_inline int __down_write_common(struct rw_semaphore *sem, int state) > { > int ret = 0; > > @@ -1310,12 +1310,12 @@ static inline int __down_write_common(struct rw_semaphore *sem, int state) > return ret; > } > > -static inline void __down_write(struct rw_semaphore *sem) > +static __always_inline void __down_write(struct rw_semaphore *sem) > { > __down_write_common(sem, TASK_UNINTERRUPTIBLE); > } > > -static inline int __down_write_killable(struct rw_semaphore *sem) > +static __always_inline int __down_write_killable(struct rw_semaphore *sem) > { > return __down_write_common(sem, TASK_KILLABLE); > } Whether inlining happens or not really depends on the compiler used. Anyway, Acked-by: Waiman Long Thanks, Longman