Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2253544pxp; Fri, 18 Mar 2022 06:47:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0znmH0TCrCCKBB1UiRL2TgAsL3H8t3LVLdCm1e832kTTKox/dws6gg7G+jRGEKvZcvM0Q X-Received: by 2002:aa7:cdc4:0:b0:419:d0d:fa07 with SMTP id h4-20020aa7cdc4000000b004190d0dfa07mr2865197edw.208.1647611247206; Fri, 18 Mar 2022 06:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647611247; cv=none; d=google.com; s=arc-20160816; b=ns8Dk7dY8Nh+fRMwqK86VD1MZVG5agS6DDcn9eV2hyqTB1v+mGcWizJBP44QKR9n2c JYHOdo9m8E5f4fTVbZRzgt2UZF7c+I2YXS+6lwAp0ZQC14m/4xWaYlv96YEyI0P76U6u fc2yq06OsVnjTiZVeOYPEPtx8veq/Xl5hfmrnndNcOoIH6Z1eUjT5qHdMcr2gwCQqBWM B+SNLcXoWYM8zRMIlFwQAYK3ED1iunbO6OKyhAHsPzkC6zFnTKNg/KrQnoOvelIi1FXR hWIimsUyHYLVOZfLH5bZjY5ZGYwY+JuoRa7dVdt/G8XO44CgkzQ2r24XOfmB/28rWlH1 UcYA== 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=o+4kjV5M7AAhRV6+HUHDlhX1FtegGYf686kx5iPLbhM=; b=heJWjWh4kBIX/5BTN2sh/6fP1XA6FgjTGmykc6nyXgwgdkYVv6P3mFg3EAQjlxiH1v E5nLmiufzPWbK3QB+6cYRRbXvbKREjaurOxnLBwbvHAY8ogGcqMJcL1rwLENRlWerw3I To7E9Z8bPbLYkVnTXVamimcp5lvUcKUCUT5AFIsqmurSDLiHVoxzHz9B42eBWVBtLupZ HvXrygOyw9PrtEAn47VQLwhkB6ZYmHo4GRHVzvyuJwx03EPc1+zn5P73qPzuWAkyvpWc lArv50Efzoa5hcrqZGpezhWDWop3/jY2Le+pvsqkvjbIZ0qwkNgXMBjAK1Z5SHCF5Hgo Pbiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=axBLgwuq; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a170906001100b006df76385b8esi1386816eja.46.2022.03.18.06.47.02; Fri, 18 Mar 2022 06:47:27 -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=@gmail.com header.s=20210112 header.b=axBLgwuq; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236439AbiCRM50 (ORCPT + 99 others); Fri, 18 Mar 2022 08:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234818AbiCRM5Y (ORCPT ); Fri, 18 Mar 2022 08:57:24 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52DC23457A; Fri, 18 Mar 2022 05:56:05 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id d15so5626232qty.8; Fri, 18 Mar 2022 05:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=o+4kjV5M7AAhRV6+HUHDlhX1FtegGYf686kx5iPLbhM=; b=axBLgwuquigWzrQ1tKUH1ihyDMq/qqvK0jUvPmXNAC7iR/iUu2O0ZM8nxF7wc0eePP HJj/1kSdWGiVc987xgqdV+5kDO3K5hA1bKKmWk8FEYPcjFQwvxU5/ZVYiis5m1RPt3i8 ty10FRALip3F8QFywhetmrVk99HiyqbHe/D0Ta1maP1fqi41EZc9+olTylIaujbyxO4a mDQ8NGNISmBK2IKuXUyNmBBF8Ib7Hv8ex27+xsTv9meKzBPUGG2uLkI/k79ang9CmlUe OkwWVtA6upsTm3XOm33SlBAqwm4jgjIk+r2XcB6MjNvIzMrlpkfqA0n1JeU5rfAwN8ZM wOsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o+4kjV5M7AAhRV6+HUHDlhX1FtegGYf686kx5iPLbhM=; b=ZsmXKCMShVxKMpRdXvouDEw1PJA4U4xJlrWFbgliOx2oKLWJM258hQWojP82C6nrXB P0RjDNf3oqmZ1DYptezNS7a3bdF6Reov1++hEfu+OHZuwNjjV63SoBEW3VxDeFeeuU/r s+qpAc1MmWFmsI7e1SQfgqj6zAPRz921u2W1YtH8NzZNNaHuCtY6E/k8czA+fdIYSvm1 rZ79r6IdrK5jW83VMfGMwx3J5Ok9GdkL85BhJ1NdzUH/cWRSlIsoEBuiMhR/VqYHCFAg qMX2x0S35W7nivujHsehXygqgwN8dRQgEUS8fm8de6fjceJcqoFQ8IhApLYwB4wZDRcp ELpg== X-Gm-Message-State: AOAM530klvlsdY7dSs/OH6Oe639tCqUhUGgjzO5YzxhHYpqla71gxDZy YdQrGrIQah56DfolxAyTj8Q= X-Received: by 2002:a05:622a:8e:b0:2e1:fee4:8ca2 with SMTP id o14-20020a05622a008e00b002e1fee48ca2mr3888357qtw.431.1647608164801; Fri, 18 Mar 2022 05:56:04 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id r14-20020ac85c8e000000b002e1d62ba775sm5690654qta.21.2022.03.18.05.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 05:56:03 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id C8FCF27C0054; Fri, 18 Mar 2022 08:56:02 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 18 Mar 2022 08:56:02 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudefiedggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhepvdelieegudfggeevjefhjeevueevieetjeeikedvgfejfeduheefhffggedv geejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsg hoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieeg qddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigi hmvgdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 18 Mar 2022 08:56:00 -0400 (EDT) Date: Fri, 18 Mar 2022 20:55:32 +0800 From: Boqun Feng To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Arnd Bergmann , Radoslaw Burny , linux-arch@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 2/2] locking: Apply contention tracepoints in the slow path Message-ID: References: <20220316224548.500123-1-namhyung@kernel.org> <20220316224548.500123-3-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220316224548.500123-3-namhyung@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, Mar 16, 2022 at 03:45:48PM -0700, Namhyung Kim wrote: [...] > @@ -209,6 +210,7 @@ static inline int __sched __down_common(struct semaphore *sem, long state, > long timeout) > { > struct semaphore_waiter waiter; > + bool tracing = false; > > list_add_tail(&waiter.list, &sem->wait_list); > waiter.task = current; > @@ -220,18 +222,28 @@ static inline int __sched __down_common(struct semaphore *sem, long state, > if (unlikely(timeout <= 0)) > goto timed_out; > __set_current_state(state); > + if (!tracing) { > + trace_contention_begin(sem, 0); This looks a littl ugly ;-/ Maybe we can rename __down_common() to ___down_common() and implement __down_common() as: static inline int __sched __down_common(...) { int ret; trace_contention_begin(sem, 0); ret = ___down_common(...); trace_contention_end(sem, ret); return ret; } Thoughts? Regards, Boqun > + tracing = true; > + } > raw_spin_unlock_irq(&sem->lock); > timeout = schedule_timeout(timeout); > raw_spin_lock_irq(&sem->lock); > - if (waiter.up) > + if (waiter.up) { > + trace_contention_end(sem, 0); > return 0; > + } > } > > timed_out: > + if (tracing) > + trace_contention_end(sem, -ETIME); > list_del(&waiter.list); > return -ETIME; > > interrupted: > + if (tracing) > + trace_contention_end(sem, -EINTR); > list_del(&waiter.list); > return -EINTR; > } > -- > 2.35.1.894.gb6a874cedc-goog >