Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp74064lqe; Fri, 5 Apr 2024 13:05:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxy1EiigKxX13IdYxs1JXy8h95SZD7gIAHF7OCLkKuvcQJGOc7X/vj29ZHp6wr6PmOPeWv4iKlFokWpD8dJM2L7HKvf6S11Y+eJYS0bQ== X-Google-Smtp-Source: AGHT+IH16sI4tP3CKOcJtuohEiZE4KhpiGOowu7fkDWq9oWBFgAd31Y4F+vHaBTidAaRT43vKTv0 X-Received: by 2002:a05:6102:1622:b0:479:dd8a:ee2c with SMTP id cu34-20020a056102162200b00479dd8aee2cmr2734808vsb.15.1712347558512; Fri, 05 Apr 2024 13:05:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712347558; cv=pass; d=google.com; s=arc-20160816; b=z3GEVmeow6JvqhKHOwydvHKZrGXgc1gMNdSa+OBjtZC01xuU2JHOfSgefDEOPBSzVr PG3soL0jIQkBhEb5+olvk5Gl6qRjzWafQl8knoKahrAaPXMMmKlxNcLCu5Ld36KrNhUl uHx8YvEY7C0PNCCySlCLyzuWXBvkjYulm0+FUKEz9l5UTEAVeK6kX0+gcGH8wWDUOmUr ffYi/w3TZ+/4ZY605D3Jtiu09U95k+QQ7T5tcY+VXavddGqxb422CuHc9XS2FPRepzQ9 FA7QjQylE5f9wCXBV3og9gws3S6nNoLaqv/OglHsku6znld8j/S6s0qCVXRWjyew0fWU PLQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=vX/8UUj3bTMhmjE/Pb7I5CpQrbYOm5sxUlxUaaI9t04=; fh=THG2lVM4shO25d7SPahJjpKqSKTzuRBnZls/7ptpAC8=; b=lcdacmdhr8hd30/08S4JTWcH/BhomgvnYJ16ck0cEwyzppw0oUgYgj2vbPotcJCmOG 7p/PzyZWEY1nEAznNW7XmwyZpYj8Jq49lfmWsjfLhbYS+bWfMy/LmoH00QU1Ew86F9zD Bct6uTwgGNUJmjnD22f54H0+Eqb1Ru/BbqP+UuRNFVDOVrOdRmlSIe3cFI19Go8BMjDh Au0gxpCjBhKiHI7y4XtSbMx7Z2bomhTqUgdBGQGCH6+kWYCzIPsR98YbnDTNlbEAR6DI 136WzCz2iBvR1BxxW9orbtvLPCFV2wlvbkpj7BOC+P0OIRcmzJg8pOcEmzQoyBY77tZw mcaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AC1BYAJH; arc=pass (i=1 spf=pass spfdomain=flex--jstultz.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133546-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 o40-20020a0561023fa800b00476dcb4f246si519155vsv.379.2024.04.05.13.05.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 13:05:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133546-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=@google.com header.s=20230601 header.b=AC1BYAJH; arc=pass (i=1 spf=pass spfdomain=flex--jstultz.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133546-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 2C5FE1C21CC6 for ; Fri, 5 Apr 2024 20:05:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4FD6174EC6; Fri, 5 Apr 2024 20:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AC1BYAJH" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99EE9173328 for ; Fri, 5 Apr 2024 20:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712347541; cv=none; b=KHLApA9Mwx9dAqfbG9X6hJO4sqNJ1ELvtXMbVTnLY9r82kjYVye+A7D6ItdMZ/DL7QlMDJqlT/CslopuUbuSEsk8KcQrv1Gmr2V07bAsSvh/TwHnCNw/obzeVyB2TkPDY5HPhNv3ovbleZvApDFYiyfJhc61S8rn2TgfikIzGYo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712347541; c=relaxed/simple; bh=kVOg6+8kVRoCisrfwR7WOhMe3mNooVqy6FvtcCAm8ro=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=HogOyoK1m+y0hqXY1V8rRwU/BAUxwpm9gGALzJtDo/Jd6Sw3Tw/ucJFWCP4ZiQM3BQrDdC693vsBuHby1j1DdrM4/+PKDgSorlKgyR4zayRHBq4HhSvjIQ5y5qft67ixU17eH0PqCmtJnjx0MbrrwHr6ASKXrrXrwJ41goFZGxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AC1BYAJH; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5d8df7c5500so1850229a12.2 for ; Fri, 05 Apr 2024 13:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712347539; x=1712952339; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=vX/8UUj3bTMhmjE/Pb7I5CpQrbYOm5sxUlxUaaI9t04=; b=AC1BYAJHhACGgPOCaUO791leGnGo9WCTlu+iTK2IJSix4fH6foWNsL4TixlW40gG0y 6OHtoa7OAwgzBIwQRtJ3YW7oaJIuLIdRGIdJlnI46oX93LWZo5ZQSAUFClZ/kRZFt69L jwYn3FyeD/p0VQEcrI7nFhWPDSIlLk7PtmETtOwlZF3KZQvuDUtQGdkb0lfQ2K6rkdF/ pOeIOaGkMa8FFPKg/orio2wMJEqH/1x7+N7fe0ir+4/6D9Yj+mcK3Y727zxtpRbX+xQr hTsUD6L5sUzA1Fbk/tL7TrMMYfIngbhQSxpngFuWp1J6jNF/0aCHAXdARzgMr0B4HJ0w 3Pwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712347539; x=1712952339; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vX/8UUj3bTMhmjE/Pb7I5CpQrbYOm5sxUlxUaaI9t04=; b=CntGm5VYnr1hrwIYRRWfSVACpUfPqFb0OJTgLk/S4oBa0kKjGnJfrL6C4gYv8o+eaA jUSjPN1rfG3krTD+VuHRW9mYQtJKR7CK6HH2ekXa4JREzjO3zpzTsLMRHiLVxbNGfc/E 2BWkv41kwpfgFZzkQ/YNTJgR7ynP8nrO3FVdZb097ua3QVb/cfCHxhGrSTGerQzxQLf5 n90QJ3bV5QxRhiOwrFIBLF5xJ/9OiMVkoBYgm6ODliTJ9FS9oM9BG2Ehs8NVIdW95wBv pnvYR59BQs8HSNVpodADRNz5RKx61G0XAM0ZqJGKEjBOwa9ZS0YVIjV608U5gO63O0PJ Kp6w== X-Gm-Message-State: AOJu0YxV+O2De2WNE6uIz/WILWa34d2noFp6tKrwJSrYuGv93p26eQSs hdUyKsfySK8qxbB4rnvG9B9IX+EXPiyaSWZD+GoSU/6zXzqhme4fJSDtHEkQgDhfL0GZcsJu335 vCvH7Pnr4vhZfHNZ2ptdX0qsVLSozhoBYaa12fpOdGE5Wo7B7jfG/G/AItMnh3ZU8t33QuyxQJy RN1bQpSaWGIs3mQhu0Nm11lMm39bpn2l5yr3I9NA0oHMF4 X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a63:5966:0:b0:5d5:ad56:55ee with SMTP id j38-20020a635966000000b005d5ad5655eemr7480pgm.4.1712347538468; Fri, 05 Apr 2024 13:05:38 -0700 (PDT) Date: Fri, 5 Apr 2024 13:05:26 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240405200535.2239155-1-jstultz@google.com> Subject: [RFC][PATCH] locking/rwsem: Add __always_inline annotation to __down_write_common() and inlined callers From: John Stultz To: LKML Cc: John Stultz , Tim Murray , Nick Desaulniers , Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" 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); } -- 2.44.0.478.gd926399ef9-goog