Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp235248rwr; Tue, 2 May 2023 19:44:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51mAtmIiqRLeeefD5g2Q5AhFb4GzPW9ES0Y66GRSdL5HNy4UBtFL6OCaZr7aWxNu2TH4bK X-Received: by 2002:a05:6a00:23c1:b0:63d:3d08:4792 with SMTP id g1-20020a056a0023c100b0063d3d084792mr28636858pfc.32.1683081878814; Tue, 02 May 2023 19:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683081878; cv=none; d=google.com; s=arc-20160816; b=XooEOM+k/FYZgPL7SGO32sfYLtEhESKC9w+KlMwBww3eQCIt4I0pvd7LuatnU5E97+ /QLbu0rk/fzmXjS6DxiZsQK0+V1jbk2KBrZR4xTeRCj3Yh5JWKSEAXyXheoztQYVyCwW 55WfBvZ+3DYwEDoypJFVKYpLsaVPK81skXAVnfgzn9U9V2Bq4R/OEmGO5MSlHJuVbEtX 7neDuyZxJZNQ5MvgaYUlQCLngOUtvQscL453Bbd8GJ8cz5K1s1whxDDtDymaLEg134vs XgXno1Qf3QXuybrkJvSITzIyqz4GoK1NSYFaWTSeA7qKWFLrCn1RftCIixiyVjJNVsq5 UluA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=kO+DuhhQhtfwQumbn93KBsOv9eGyW13juEx1DZY9eo8=; b=vO9ahSGsXfd4q3OVESQPakuhzG8GOIVjH7PV2L+3z40POH5/g7ilAlunAVpIxdS1df +ridMCVbyjQ7rf/QsDMVsLKVMdzlPV+rfpuCMnszD+i8jzD7e1zh0J9pWHVmt55J+St0 d76JNGdYjz8QAutPM705gQfpHiTHPNAMwPCI1/Ib3OXfTt/mqVk2rm4PgG5ckNldB7P1 RSn4w/BPw4Y1LCjU5f7C6q2HQL/brdLsJuLl42gE2apqk5wBmG+XTXD61gEkI4k3Ssc8 AGh9gB799vf94CCh/PR9bxHvVS9b01ZnXi0xISKbcm1OMW3Xgtwl8+AatpP2dkkJ1az6 jmhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=a6o+B30X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 3-20020a620503000000b006430573bd4fsi1821858pff.66.2023.05.02.19.44.21; Tue, 02 May 2023 19:44:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=a6o+B30X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbjECCeH (ORCPT + 99 others); Tue, 2 May 2023 22:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjECCd6 (ORCPT ); Tue, 2 May 2023 22:33:58 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D590D3C26 for ; Tue, 2 May 2023 19:33:54 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-528ab7097afso3875925a12.1 for ; Tue, 02 May 2023 19:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683081234; x=1685673234; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=kO+DuhhQhtfwQumbn93KBsOv9eGyW13juEx1DZY9eo8=; b=a6o+B30XzCwYla9TMl4aF7xYlJdinfkn5QrcDKbO/kRfUcLzUZgqHEQ+SObPwAqORx Eq0Ju3xXQQtN6rhLYdUjENVIBwLODb7QZ4B2DYBV4KkNhtZrKrYQHHBo46qCpA/ph6tR dM+6//+jahItnFuFomapyiOWGgu7NRob3RIbp7gJb+7WiLfXrwapkNVMdNNsf5bvtTkP qz6c2BQFSt9KbIA2TiRsq334NOijed/UPAu3Tb8uIjBy1mbHeT8DzxOJGUNIOwS5a2Ay wjRyRJQX4JODOBelKXynhlvUnRTHrKP84hPfpqhCiFMA034s5onAWxpkt+jN46W5kfx+ 4lyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683081234; x=1685673234; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kO+DuhhQhtfwQumbn93KBsOv9eGyW13juEx1DZY9eo8=; b=TKSEGM4dwxiM5DpNgX0jsqEAxlJQsvdluCr4Hg4XU+ASgQngBbn7aKJIeDlqmn0ev5 p8VxEQWU2uBw5xBI+ZWhSBmimZ5fF5yORfxDKrUqaOZ/baTe18GhsYAg+z0n1f+DF7m1 nH7oPffPOxKM99+vTEbZrAXqS4BA+YnlLWpfhD4AQXdP66na9+ysz83Zxm+s52WNYi1q 09+w0c3j0tOP5xG0CF0+C64ooUoe9hicSZMmb6Rki4jtPXAePgDkF4KZTVUgrFfyhTsX 62ScnP/JSG7zj9Z/MAHm/a+LE6xHVRiA9K0azmFaxxRE/ua1XEUPGH2yyyZ3CM+6KCwQ oViQ== X-Gm-Message-State: AC+VfDxsMy2pwVUOaqVTt0ctIddOTmuWCR+jxeKUN+RlLaKdoVZ7+6Nf C02lPn5CZAOXAdt+O0vaxRX8xcytnG2OmYBgz6DykAb93hGE3EZg3lEUsn9Ck4BnG97l7NOVkg3 CBA7ZZZi6mGF63K2Lu/8IHZiRsikJOke7knG9W+k6ILRr8mogsga/RdcJkecrwIK1jEoatF4= X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a63:28c6:0:b0:52c:4227:aa60 with SMTP id bs189-20020a6328c6000000b0052c4227aa60mr138888pgb.7.1683081233936; Tue, 02 May 2023 19:33:53 -0700 (PDT) Date: Wed, 3 May 2023 02:33:51 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: <20230503023351.2832796-1-jstultz@google.com> Subject: [PATCH v3] locking/rwsem: Add __always_inline annotation to __down_read_common() and inlined callers From: John Stultz To: LKML Cc: John Stultz , Minchan Kim , Tim Murray , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , kernel-team@android.com, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham 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 Apparently despite it being marked inline, the compiler may not inline __down_read_common() which makes it difficult to identify the cause of lock contention, as the blocked function in traceevents will always be listed as __down_read_common(). So this patch adds __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. Cc: Minchan Kim Cc: Tim Murray Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: kernel-team@android.com Cc: stable@vger.kernel.org Fixes: c995e638ccbb ("locking/rwsem: Fold __down_{read,write}*()") Reviewed-by: Waiman Long Reported-by: Tim Murray Signed-off-by: John Stultz --- v2: Reworked to use __always_inline instead of __sched as suggested by Waiman Long v3: Add __always_inline annotations to currently inlined users of __down_read_common() to avoid the compiler later doing the same thing there. (Suggested by Peter). --- kernel/locking/rwsem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index acb5a50309a1..9eabd585ce7a 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -1240,7 +1240,7 @@ static struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem) /* * lock for reading */ -static inline int __down_read_common(struct rw_semaphore *sem, int state) +static __always_inline int __down_read_common(struct rw_semaphore *sem, int state) { int ret = 0; long count; @@ -1258,17 +1258,17 @@ static inline int __down_read_common(struct rw_semaphore *sem, int state) return ret; } -static inline void __down_read(struct rw_semaphore *sem) +static __always_inline void __down_read(struct rw_semaphore *sem) { __down_read_common(sem, TASK_UNINTERRUPTIBLE); } -static inline int __down_read_interruptible(struct rw_semaphore *sem) +static __always_inline int __down_read_interruptible(struct rw_semaphore *sem) { return __down_read_common(sem, TASK_INTERRUPTIBLE); } -static inline int __down_read_killable(struct rw_semaphore *sem) +static __always_inline int __down_read_killable(struct rw_semaphore *sem) { return __down_read_common(sem, TASK_KILLABLE); } -- 2.40.1.495.gc816e09b53d-goog