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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C24E8ECAAD4 for ; Thu, 1 Sep 2022 01:07:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C7826B0072; Wed, 31 Aug 2022 21:07:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34F6D6B0073; Wed, 31 Aug 2022 21:07:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C8ED8D0001; Wed, 31 Aug 2022 21:07:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 07D066B0072 for ; Wed, 31 Aug 2022 21:07:56 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D86A0AB8D0 for ; Thu, 1 Sep 2022 01:07:55 +0000 (UTC) X-FDA: 79861729710.11.9904B73 Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) by imf08.hostedemail.com (Postfix) with ESMTP id 897C5160054 for ; Thu, 1 Sep 2022 01:07:55 +0000 (UTC) Received: by mail-yb1-f177.google.com with SMTP id t184so6587107yba.4 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=7EfJHJ67y2x3oBgihfqBT6Y8I07Ctt+WfrnqosCJos5io/Na2+VxMYK38/8BZ0MYCl Y79qJm9ODauHyHZ8+N+Ko1LlJOJ87i/qxtxZgz6VFPxitWaBdoz/H4izB2b0QF2iZt7c 4gFVOF3DzVrm2VQfwm5x6xXhgKF+IHSQdF+WwoZu0OyAUcYry36FyjANt3k+XBoHsTBX 1PMCoR8aEzrmUoyxpWCM5yJr18RbKVAOcwGdy+lwG9KVIGpQX1wQgTbLfAhTv5zwZ38W 8TQQJFAA/ugHd0mt9OAXDG2Xl39kcbgEO2J8qcge7NKVvGLiLTSGuJG8MvSPaJC0INB8 S//w== X-Gm-Message-State: ACgBeo3ARx/aLLTqDcfgwjs3cP2VH3Em3LmFOLYH6yAPy5LPGgqGgIlR 4D4Ugaiumo7RplqeCA+139VpLOhDPNjdX0QaWc8tCQ== X-Google-Smtp-Source: AA6agR7ANRZu1y3V5ec1pN1knn4GFpXcEWezad8yEa+jyRtwuxFDik/95LNfhWenWi2n9p8vw7Ebn9CJDR6Mcs4MSyE= 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" ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=FN6oNUdW; spf=pass (imf08.hostedemail.com: domain of surenb@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661994475; a=rsa-sha256; cv=none; b=pHtAF4zEJbIyjgP67nkKz/h6acVXNon54L2uorOneloa/+Uhtgp1vDCX9uwJ6Ocr+wukiL nwPR+SrtnQIW8JunW9AQkQyHTOWNtMY5LL+o3P5z4WgRjUiLtzfuVtNkQ2h6Pwaa5EtdTk D7O2XP8YCdz0oUI1ZjjjvveGyxMTdQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661994475; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MRPzoJhQ6jRX3IlC8DX7IgvLpQbZlMnsgnvZKuuei8w=; b=wDIFnHXbZNZaEutfoBX03gH3FS/dH8Keidau3LQa0mLANEABaW1hc/P3yzam/fUE3XdrKO zSOi3DiC7b4IqDefBEuZue7grDlaaFTgOEeW8bYnqFimJ0uUwfdlxVOgw8wb10Hd7z0T2X TIsX9KCuUb4iamOEHsc/ICmKiSagreA= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 897C5160054 X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=FN6oNUdW; spf=pass (imf08.hostedemail.com: domain of surenb@google.com designates 209.85.219.177 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: rzhbrb3htoc9qcbnghktstoaqsk8dyep X-HE-Tag: 1661994475-411619 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, 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. >