Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4085871pxk; Tue, 22 Sep 2020 09:53:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq5ZdUBJI33VxqVSe1sZAMffRQpxw6zMoNbfA6TcZFKd2zgGWmhIx+QgJ61rmHqm9JMRpD X-Received: by 2002:aa7:c2d6:: with SMTP id m22mr4871050edp.311.1600793588659; Tue, 22 Sep 2020 09:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600793588; cv=none; d=google.com; s=arc-20160816; b=p/141CnAYuHmHRZchHqeCDokw70UjCxHs8tb05OYLv8w4Lf7RZpfqQCi/dxB3mPmzO 3UjdZIcWbfvygj3lCcQ6pgB6dB0spNaSDCIlV9tBguoB7aNZvYCPEjzvtJXV59wAzsXr tq1YUsKBpHSxfonf3l1StkLrFh/JyMcDAPeQ8izve7rm9TOwvwwdvryl+431ZzpsN/zz 793gDtVXmD+WtpNa/+ARgyqU4mb6HG/Fof+5NAeW+SdkxISTbHePf/xlgaP0lJ14te1s huCKjT2k0gJt++3RsUlQElmXbQJBM5HgAjAvnCX7joOxUKyN3EoWVa27/klXwyfAYRJ5 qhpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=C1BVSP0gnSt97D3F5va9VjtqoyLu+Qs69/+fAAJRRsQ=; b=Z6skeV0KR0TfBP3qFjbB+B1J9WRjHqYHtii4CfwrSgIqu21DlcEDVrs8Bytf6lRqkL ZbT/OG4fcY7FgpuzLvGY+EAS59WnzGY8iJhWG8AZUaMb1+Id4nd4n3ZCUqWvaLb7y7Qe 4seVuSS+Y0iaam7AtTbOEQKLv0nbzddQX/xStu8aGLfnCLnPJWQfSObkyriNIijrhIp5 8Pj8VkU3VcOQftBdAA2kBfDP6BKK8Q0B9HtnhOKI3t9nhhNIgrYvvmIuaVzPMQIfSE5K UhBpw9XcXYlxSPWxmavDlKEC9fLjl9mNV63Tc75QN3Ypg3ZxxHSXiMMbZuvNRLwAiuWd wChQ== ARC-Authentication-Results: i=1; mx.google.com; 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 h23si10531559ejd.576.2020.09.22.09.52.44; Tue, 22 Sep 2020 09:53:08 -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; 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 S1726603AbgIVQvQ (ORCPT + 99 others); Tue, 22 Sep 2020 12:51:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:37450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgIVQvQ (ORCPT ); Tue, 22 Sep 2020 12:51:16 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 23A9822262; Tue, 22 Sep 2020 16:51:15 +0000 (UTC) Date: Tue, 22 Sep 2020 12:51:13 -0400 From: Steven Rostedt To: Yafang Shao Cc: Axel Rasmussen , Ingo Molnar , Andrew Morton , Vlastimil Babka , Michel Lespinasse , Daniel Jordan , Davidlohr Bueso , LKML , Linux MM Subject: Re: [PATCH] mmap_lock: add tracepoints around lock acquisition Message-ID: <20200922125113.12ef1e03@gandalf.local.home> In-Reply-To: References: <20200917181347.1359365-1-axelrasmussen@google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 22 Sep 2020 12:09:19 +0800 Yafang Shao wrote: > > > Are there any methods to avoid un-inlining these wrappers ? > > > > > > For example, > > > // include/linux/mmap_lock.h > > > > > > void mmap_lock_start_trace_wrapper(); > > > void mmap_lock_acquire_trace_wrapper(); > > > > > > static inline void mmap_write_lock(struct mm_struct *mm) > > > { > > > mmap_lock_start_trace_wrapper(); > > > down_write(&mm->mmap_lock); > > > mmap_lock_acquire_trace_wrapper(); > > > } > > > > > > // mm/mmap_lock.c > > > void mmap_lock_start_trace_wrapper() > > > { > > > trace_mmap_lock_start(); > > > } > > > > > > void mmap_lock_start_trace_wrapper() > > > { > > > trace_mmap_lock_acquired(); > > > } > > > > We can do something like that, but I don't think it would end up being better. > > > > At the end of the day, because the trace stuff cannot be in the > > header, we have to add an extra function call one way or the other. > > This would just move the call one step further down the call stack. > > So, I don't think it would affect performance in the > > CONFIG_MMAP_LOCK_STATS + tracepoints not enabled at runtime case. > > > > Right, it seems we have to add an extra function call. > > > Also the wrappers aren't quite so simple as this, they need some > > parameters to work. (the struct mm_struct, whether it was a read or a > > write lock, and whether or not the lock operation succeeded), so it > > would mean adding more inlined code, which I think adds up to be a > > nontrivial amount since these wrappers are called so often in the > > kernel. > > > > If you feel strongly, let me know and I can send a version as you > > describe and we can compare the two. > > > > These tracepoints will be less useful if we have to turn on the config > to enable it. > I don't mind implementing it that way if we can't optimize it. > > Maybe Steven can give some suggestions, Steven ? > What you can do, and what we have done is the following: (see include/linux/page_ref.h) #ifdef CONFIG_TRACING extern struct tracepoint __tracepoint_mmap_lock_start_locking; extern struct tracepoint __tracepoint_mmap_lock_acquire_returned; #define mmap_lock_tracepoint_active(t) static_key_false(&(__tracepoint_mmap_lock_##t).key) #else #define mmap_lock_tracepoint_active(t) false #endif static inline void mmap_write_lock(struct mm_struct *mm) { if (mmap_lock_tracepoint_active(start_locking)) mmap_lock_start_trace_wrapper(); down_write(&mm->mmap_lock); if (mmap_lock_tracepoint_active(acquire_returned)) mmap_lock_acquire_trace_wrapper(); } -- Steve