From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 124C8C2D0A8 for ; Wed, 23 Sep 2020 10:04:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7349C2076E for ; Wed, 23 Sep 2020 10:04:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AnF9bkr+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7349C2076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CDED26B0055; Wed, 23 Sep 2020 06:04:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C8FAB6B005C; Wed, 23 Sep 2020 06:04:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7E8F6B005D; Wed, 23 Sep 2020 06:04:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id A309B6B0055 for ; Wed, 23 Sep 2020 06:04:55 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 60AF43625 for ; Wed, 23 Sep 2020 10:04:55 +0000 (UTC) X-FDA: 77293892550.09.book05_3e03b7127155 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 47C39180AD807 for ; Wed, 23 Sep 2020 10:04:55 +0000 (UTC) X-HE-Tag: book05_3e03b7127155 X-Filterd-Recvd-Size: 6130 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 23 Sep 2020 10:04:54 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id r25so23059862ioj.0 for ; Wed, 23 Sep 2020 03:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=U3SJLMlf/gmjcb1bIq1gmYKwOwQU6kOmc4/dD7hBTLI=; b=AnF9bkr+Aofx+XR6HFARYdNts9+MCFj6xElg03TL4mbKqwB33/RxxUR1B3JuBGn6Ep lKE+ysLgFx7oo3ZOCViOcEHvaYNSlzitXJTRbSe4rP8BqboWFVVyfQoYiW65+8JMvFv7 VQ3Yr1iHP1QGE17uMY81/BtOdLDHWrDH9jGlFyzUwnXxSM61fNUOCHXMIADit8pK09eC VPjY3Sn60haZM8/pIODuSTwT7kva4LPnIYQCO9yY49V3p3fItl1B6KGp1nw4J41W1Kxb CyM8judgx+xv6GXc8AS77zzqWLaSBKmyWTjz7kWNtRZNbf8tMG5QnzQjZz2uVrvzxMhw uGdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=U3SJLMlf/gmjcb1bIq1gmYKwOwQU6kOmc4/dD7hBTLI=; b=rQAWQii+jrcOSap1CxBV11C6jmAMCzfJoe/nUNwJ6+QlgVtoS0lzXZ0esBxVpuImBh Kxw4m6NkxFpRXArtZW4+8GpL+JAmILJlegySEnKi7T8DP5s/ewL+1FkF+F3eYfd0wz23 0/fweZNbi49KBp7lwaRSBnGhDZs44PAuVO5c8BAqTR64/aoCCEt68n8BPRyFN9qyg2lV MJazp4Prmt0a9cuy7a7SgAUU0YEBIZjJJ+7GwwALKAEWG8hG1efmrsXHbXfSva8j6OYf kuvAOiadavfFiWLYmh4CYYsE0+RXU13m4gh/mUf1mKE1eGuBUZhAevaaH0t9B0j0HgB1 ks6w== X-Gm-Message-State: AOAM530KwgnK9msfl1qxiTFpsZGrbX9s20xAKtwt//liDBKVH3xy8h0G tsSKnGhyUOc/1EtXRoYufhrvHUUnb368Kw+AvMI= X-Google-Smtp-Source: ABdhPJxqbN0Ql5FC1qxjeBTn3rLaRsch4PfTVq6Y5dMRz+dkBBngdnkN1RXN+z39qc0QoQMv2mKP5RT5jG1+H2xQhbQ= X-Received: by 2002:a6b:7005:: with SMTP id l5mr6728218ioc.10.1600855494306; Wed, 23 Sep 2020 03:04:54 -0700 (PDT) MIME-Version: 1.0 References: <20200917181347.1359365-1-axelrasmussen@google.com> <20200922125113.12ef1e03@gandalf.local.home> In-Reply-To: <20200922125113.12ef1e03@gandalf.local.home> From: Yafang Shao Date: Wed, 23 Sep 2020 18:04:17 +0800 Message-ID: Subject: Re: [PATCH] mmap_lock: add tracepoints around lock acquisition To: Steven Rostedt Cc: Axel Rasmussen , Ingo Molnar , Andrew Morton , Vlastimil Babka , Michel Lespinasse , Daniel Jordan , Davidlohr Bueso , LKML , Linux MM Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 23, 2020 at 12:51 AM Steven Rostedt wrote: > > 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 Great! Thanks Steve. -- Thanks Yafang