Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp151271rwe; Wed, 31 Aug 2022 18:29:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR49KT2vyJWUGcQ/osT2zXjlqhLtPgW+45idotZdAs6z5UkHOUdtJ30ItsS8c4oY/nEIRHKT X-Received: by 2002:a17:902:9a44:b0:171:3541:2c75 with SMTP id x4-20020a1709029a4400b0017135412c75mr27720296plv.15.1661995770383; Wed, 31 Aug 2022 18:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661995770; cv=none; d=google.com; s=arc-20160816; b=TpdLznoMzqfmD3zXRb4yHCl9lcDkeGhrweg4eWTAHfl6jrM0/lbF+74HlOxU0gHP+w y/JTDSAbg+omIq4t7K/dQz/zrlg1Mq1FMMImUAHMFSzxQK9SomDxylHw3hWxQYgYF/zu 1FoLkFBV30Pas8TxmiFYxQMwUudf/aRDDQieGmDxc2rFxA6Aa0+9QJY+PepOwnNuOfsJ M5NC96TFzadLuOO5ggfptndp4t3x+aevRRg6VTQqNmR4R8P7LcDD6nM6LLYpJypNLNC1 lhFUmkwz81RlSJ6VuBPntKQbGIQoTP6Y54SfDM4Wm7hXuLbpjaeu37JD/hcduX1ijJak HKMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MRPzoJhQ6jRX3IlC8DX7IgvLpQbZlMnsgnvZKuuei8w=; b=jJ7khqQ6c6MDgKCF+CS5wxiosW+Ai4Ri0KTaAkVRvsFyUu1gIvdMNnz7mgCXB/rE0z frXolOZpJLlZIpSJDrLiAh7EL7DyDJxnkKAjU12VU7GSXuvYAH3Hn2XHWalAvle9e3ZA T2yOSk12X8McEOR/MtklC2zKqGXHqtfBaM0xfcarznerJmykbiuU75WKZxmWSDjgh57+ kNwVUdb3Jc9ftddajhHwISh8D/d3C2XdZXAIqiW+ipOM9p6TT4oxYMRHJqgScNG5S6zr Oi1pcb5Ax0/XHKgbq/J8NfLKeIwGKht8OqxA4LUZCll/A7yK1JArXNw3Dak1N0tBzbT2 EKXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FN6oNUdW; 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 bf17-20020a656d11000000b0041c86b0e7a0si6705206pgb.741.2022.08.31.18.29.19; Wed, 31 Aug 2022 18:29:30 -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=20210112 header.b=FN6oNUdW; 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 S231743AbiIABH7 (ORCPT + 99 others); Wed, 31 Aug 2022 21:07:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbiIABH5 (ORCPT ); Wed, 31 Aug 2022 21:07:57 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91781EE6B5 for ; Wed, 31 Aug 2022 18:07:55 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id e71so6602068ybh.9 for ; Wed, 31 Aug 2022 18:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=MRPzoJhQ6jRX3IlC8DX7IgvLpQbZlMnsgnvZKuuei8w=; b=FN6oNUdWK/epLWx1TsL9yA3judc8GEWbPUlFBZx3N+obm1zvmXwKLTgA0C+din1hae QL+aeoxudtTxFElhfOjbFrb5XsjBAilaB08Ldofl1XN7K/KLlXYDWHTq4s13vSXmuj5f DKOIAo7JDYtLr+88kw7IWfUfQEtwzvbREYO0F51ITJHJcS5BlsMkaJFVMWN04WfbWge0 QaMLxE28PQcRoEcCdCRT5hYYcc5qJq1t6S50Lj3dBP+TXgyTlXN6pUj2nAiR7uqNJFnz LBjn/+WoYkZm8EFAaPai3sk01dRp3NFnU9eS/Pc/JsqSX+SuHO7G2QXvivbbuPpvEXP7 8nRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=MRPzoJhQ6jRX3IlC8DX7IgvLpQbZlMnsgnvZKuuei8w=; b=WtG/o+y0kh9BQoA1gbR2ECbHiWqPWabLfF4UcNw/LG937T229vE30obckxL7OR4x8i HbPzNBXtSKBBWngSH0ei7fxUja53Eyon+XF4oYm/AEwQBlJmTYMRJcB8v9XF1cYGUL/l s3hR0Nr2fBUE/o9krRRrEZOTN2bJmdtLU8UrjFhgiMhnRy/MihPXYqNXCwmpv+jwND8h azIXxsgu6+74kcUJXWGGpIz0b7Jo6p5Bp5EUf1fk1cHiHrrCfQtI7xINGwwvQD3KjeuF 8q2IZDMH5CCKmX79rUxK+21zug64KEIKDa+iOdVxEv6SqX+3Amg9Lu7gpQAmP80P0d44 vySg== X-Gm-Message-State: ACgBeo0zHa4ezwzskuVMK2HpRdMKARagaLg/e5lN5PfGzvXKCdIUp0Vu ysbyrj0R0T6GUxq+29IVMOlSB+NlgmRxYgmtxevf8g== X-Received: by 2002:a05:6902:4c7:b0:69a:9e36:debe with SMTP id v7-20020a05690204c700b0069a9e36debemr14531815ybs.543.1661994474639; Wed, 31 Aug 2022 18:07:54 -0700 (PDT) MIME-Version: 1.0 References: <20220830214919.53220-1-surenb@google.com> <20220830214919.53220-11-surenb@google.com> <20220831101103.fj5hjgy3dbb44fit@suse.de> <20220831174629.zpa2pu6hpxmytqya@moria.home.lan> In-Reply-To: <20220831174629.zpa2pu6hpxmytqya@moria.home.lan> From: Suren Baghdasaryan Date: Wed, 31 Aug 2022 18:07:43 -0700 Message-ID: Subject: Re: [RFC PATCH 10/30] mm: enable page allocation tagging for __get_free_pages and alloc_pages To: Kent Overstreet Cc: Mel Gorman , Andrew Morton , Michal Hocko , Vlastimil Babka , Johannes Weiner , Roman Gushchin , Davidlohr Bueso , Matthew Wilcox , "Liam R. Howlett" , David Vernet , Peter Zijlstra , Juri Lelli , Laurent Dufour , Peter Xu , David Hildenbrand , Jens Axboe , mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, changbin.du@intel.com, ytcoode@gmail.com, Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Benjamin Segall , Daniel Bristot de Oliveira , Valentin Schneider , Christopher Lameter , Pekka Enberg , Joonsoo Kim , 42.hyeyoo@gmail.com, Alexander Potapenko , Marco Elver , dvyukov@google.com, Shakeel Butt , Muchun Song , arnd@arndb.de, jbaron@akamai.com, David Rientjes , Minchan Kim , Kalesh Singh , kernel-team , linux-mm , iommu@lists.linux.dev, kasan-dev@googlegroups.com, io-uring@vger.kernel.org, linux-arch@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-modules@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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, Aug 31, 2022 at 10:46 AM Kent Overstreet wrote: > > On Wed, Aug 31, 2022 at 11:11:03AM +0100, Mel Gorman wrote: > > On Tue, Aug 30, 2022 at 02:48:59PM -0700, Suren Baghdasaryan wrote: > > > Redefine alloc_pages, __get_free_pages to record allocations done by > > > these functions. Instrument deallocation hooks to record object freeing. > > > > > > Signed-off-by: Suren Baghdasaryan > > > +#ifdef CONFIG_PAGE_ALLOC_TAGGING > > > + > > > #include > > > #include > > > > > > @@ -25,4 +27,37 @@ static inline void pgalloc_tag_dec(struct page *page, unsigned int order) > > > alloc_tag_sub(get_page_tag_ref(page), PAGE_SIZE << order); > > > } > > > > > > +/* > > > + * Redefinitions of the common page allocators/destructors > > > + */ > > > +#define pgtag_alloc_pages(gfp, order) \ > > > +({ \ > > > + struct page *_page = _alloc_pages((gfp), (order)); \ > > > + \ > > > + if (_page) \ > > > + alloc_tag_add(get_page_tag_ref(_page), PAGE_SIZE << (order));\ > > > + _page; \ > > > +}) > > > + > > > > Instead of renaming alloc_pages, why is the tagging not done in > > __alloc_pages()? At least __alloc_pages_bulk() is also missed. The branch > > can be guarded with IS_ENABLED. > > It can't be in a function, it has to be in a wrapper macro. Ah, right. __FILE__, __LINE__ and others we use to record the call location would point to include/linux/gfp.h instead of the location allocation is performed at. > > alloc_tag_add() is a macro that defines a static struct in a special elf > section. That struct holds the allocation counters, and putting it in a special > elf section is how the code to list it in debugfs finds it. > > Look at the dynamic debug code for prior precedence for this trick in the kernel > - that's how it makes pr_debug() calls dynamically controllable at runtime, from > debugfs. We're taking that method and turning it into a proper library. > > Because all the counters are statically allocated, without even a pointer deref > to get to them in the allocation path (one pointer deref to get to them in the > deallocate path), that makes this _much, much_ cheaper than anything that could > be done with tracing - cheap enough that I expect many users will want to enable > it in production. > > -- > To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com. >