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 03659C369C9 for ; Thu, 17 Apr 2025 17:50:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 663032800CE; Thu, 17 Apr 2025 13:50:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 613BB2800CC; Thu, 17 Apr 2025 13:50:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D9862800CE; Thu, 17 Apr 2025 13:50:53 -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 2FCDB2800CC for ; Thu, 17 Apr 2025 13:50:53 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 994EC140282 for ; Thu, 17 Apr 2025 17:50:53 +0000 (UTC) X-FDA: 83344276386.15.BC572A1 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by imf23.hostedemail.com (Postfix) with ESMTP id BF6FF140003 for ; Thu, 17 Apr 2025 17:50:51 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KEDdNo0n; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744912251; a=rsa-sha256; cv=none; b=ygCvkrX9GgIOT/IvWju0b20rheho+9bTTrnAIJ3P9LjFGHmr/X0pKlNPMcgCWoQxhwVJRX 9nx5aWAx24R9FRRCtNBtNGB7XSQF774ETPj/DnZjyDg1OoSs+jrD3JMf9n5QE9jzVDeX5M hcEjBGsF2WyyieEzGKAQDGJGXetNnnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744912251; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wY6w8TH9Q+VdzLtPkQXB54SVYMjTjltbub+aLf76WgY=; b=dtld8HcO5yR6jZQ2bAQQB1lCi3w434Tl1KC6m8XOpfa4XSqpYlgbdQKgRcc9mZbDrQpntz Fz05gbvMWho/Kw5mPIVIYIgHDOkxvX5h2Itl/Zp5BLxJBFr2gTvAMM+j3kdtSsVJSh0eqJ Ufg4EViOonjznHEnVFQu2cfShBCmZDM= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KEDdNo0n; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.128.54 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-43ce70f9afbso9506865e9.0 for ; Thu, 17 Apr 2025 10:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744912250; x=1745517050; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=wY6w8TH9Q+VdzLtPkQXB54SVYMjTjltbub+aLf76WgY=; b=KEDdNo0ng9rhy+4lk9qZtUcvMqrKtqQ3YJPhYkd8lgxiubwqLg3I+KGm3H2h10c4HG 3DDDfh5qYusJOALoCPJm4ycqSrpxjbMYOT4O21hl2L96M5S89DaQQo2Wrry2vYMM+uqG fH8xyPoMWDC0nMKT3FqeDdVZhGi05JeajXMOptFVSJZdknDKQauBvARRME6DXk+Sx0/a flaBRYmOOeQ1x7Op9l6P/fuA4ubzaC7E6qFArcEdOx2G2h2RO2TfL9h5ZBMj+PLW2vq/ Y5uCH3masWLYpCpPSKfBXV0cJmNYZ1/+8B6iqpUMYxRjaqBvFeCOeF/1N2fymV6I2Oee 9sMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744912250; x=1745517050; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wY6w8TH9Q+VdzLtPkQXB54SVYMjTjltbub+aLf76WgY=; b=Qrm8Yy+sMC9MG2bIaqk3mhnfkdYykURhT7efcW5E/imqCQ2UEeF9YR3DEA/1/Dpodv c3y2bkzMhV6y0zDF6JwuWgRyYWxr89mqAcAwK2ceTuAZAe4Qx8IIUhzwPKLD5PKBTkts QrVOhfHyRiaLIGkFYsA2x0i/suX0k4pTaJqutIo0gqR/4c050I6Z++Q7ncmf9j9tHYri xtkZdrl+etic2lHBAAmtlSKDDaQ0JAk49fczTfAGP4Zu6vhaeZFBx6lmuaamMkEQvq0K GUzy4EMFbKsiHy6Xq1oSyPubRVyV8pQLfPdPXbK6JgrlS/U4VnACarN2APfZong8pcFE /Kqg== X-Forwarded-Encrypted: i=1; AJvYcCV4Pcq+Gu8T87BIgnMr9KC+qNgqEb5MipU0r7H06hTqsvFJ9+FyYNHrVaXtt+Nem+6ycZIT8E1b2A==@kvack.org X-Gm-Message-State: AOJu0YxcnMn/ahGIgnKryHBx39nC2Pt7uxPkqNXo1EtZge5lJRI1+Av6 ywxCZvpm/iAZJSBpSDQU4py9cz2LLMDcSDmNhAYF2JgQqsgew1Kj X-Gm-Gg: ASbGnctwfXXypfXt1Fr0BWa3n2iMbFP24gTqRGLmWJpMa5GegekkbOqYM1D8ZFAvxoK 5QF1Vlts6PROX8YncyZ/wpIqVwzXEOx0tWEBmQgJdGkb+nhFexdJeUhNE8xoFk1AEhw8zaS/3w2 fujoDl0m9zVB/ymni1NqMscxzy52ecLsblgEFsSkRkBbU+wVqoaGFyk1crbcZTYU+7WSOvi+29I hn08/TRkfLCSEvWImPhZFqDnhqwUD7JYAyFppMsevNVGLKy6oqpwbLDpGVRJq0RnKf69L/bC9sM WToZHi+XCNKMTuLPOPTYO18qwZKyK4LAHFmn6yMTjKPoszobhzIyGExiuQh9iBum9YyCYjumQP7 0U96RkD1nnpLc6eiLAfG73T2rgD53tYTutQ== X-Google-Smtp-Source: AGHT+IFx+EV6MaaXa09YxGdxb0I1bxWeMUdH/lPcryr996yGdvxOdd7NFB53GcnVDqF0YV0bnQ0+Zg== X-Received: by 2002:a05:600c:5012:b0:43d:b51:46fb with SMTP id 5b1f17b1804b1-4405d5fd33bmr78066495e9.2.1744912249911; Thu, 17 Apr 2025 10:50:49 -0700 (PDT) Received: from ?IPV6:2a02:6b67:d752:5f00:c46:86ac:45ea:7590? ([2a02:6b67:d752:5f00:c46:86ac:45ea:7590]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4405b4c7eeesm64545105e9.1.2025.04.17.10.50.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Apr 2025 10:50:49 -0700 (PDT) Message-ID: <25ac1d9c-c7e4-4dcf-b297-254fa51c6f2a@gmail.com> Date: Thu, 17 Apr 2025 18:50:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] alloc_tag: introduce Kconfig option for default compressed profiling To: Suren Baghdasaryan , Shakeel Butt Cc: Andrew Morton , linux-mm@kvack.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <20250416180653.3438158-1-usamaarif642@gmail.com> <72pac6pkjebt6xo7engiuuu7r3zr7fu6fh6bj77f22m7gslxgr@3gjawofplas2> Content-Language: en-US From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BF6FF140003 X-Stat-Signature: g5gguxxbitoo11dfmsct4aoxxdxf1tzn X-Rspam-User: X-HE-Tag: 1744912251-95158 X-HE-Meta: U2FsdGVkX1/otN1ASWYYo1gPrVEyHjTKapyPBoHIRLQc/QF02yhh9eq5qdaiZUDBQBk6MNaEhln6PEUQ4LsA2DKKattuDf5F1/IOw7sm44lZmfxw9f3PrD/3mk2tgqBmwvVAAcD1DV+VKiRytUVJ2YdSE12DSubqnvsSaHS4Xj0Pke6ZVjnBWHNlahR/K4CSLE6S1H6k44Qf0AND8Bd83OqfXkzpeCOWYKgoqDK2TOuTpfwv7Vm42uS9arYjddMpRacJxgGfKQYYbkHW+K35cdN2rUhdxtS9d+Fn+5Jjr8iv6dCxHBPHywnhanBb6u3a7OB/TAjYzmghzlE/k4xnqDb6mw70pRIVjoulSBSeyc6QsI5jxpPdoWsRhNI9sGpTXiRmHSvxqOX+U6IlTb+xj/lnoyLwoddxAgoSwnGbNA8eSMPmCIDe5KT1rfISwoApvog2MDp45gfjPyi0RBvzHhZQ7bqhxz2Id/nw6Oty8PjDypLttkvOKEEjA01hAPt/ukIeooJhbgeyAxMKczeAGNIdG11wkgybFN+JrcTTex4kdTbUijOX08QAttz7BgonRLjDXujtcrF32DgAk6FdIuAmLekpfKGsGtVoxrdxFDNRbryinT95d28yLY0e7mHbskxregjyJVXG317HMRN/sWQ005HdLqFz0obJYFN5RnbrEfiEvRgkw+q6IcFZfuxIARD9ETLeOgFYlUt9Pry6/5Ke5yyT3LQAVPNUXtqDAk4B1DJ7I65TXOKwCeue8ixMRpvmuHsaLBPs26x2/BkNHBitVSt91ng8wGYjadEjXkgDO3O8TKSSBW5J++LY0+ygRvI9blbNNjZ1OpLJyKrfN+aKOYICxWPiurUPubVMceByOl/ndn2zrU5FKlOk7Rmgul+07MXeS1RGziODHEShbxOl5Y+85aIxc0k1Kbr6Wm1AKOu+GVyj2JgtZmsSh1Lpw1v1Wj4ZF4oBmEAcuLg CAD54HoD Hs76FNY/ZhQ/BWmxyp5Cq6qDIcsScG2nDt5v0PHsTrfMW6SYOuSVpxD0SU6LKDEgAfm/b X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 17/04/2025 17:00, Suren Baghdasaryan wrote: > On Thu, Apr 17, 2025 at 8:47 AM Shakeel Butt wrote: >> >> On Wed, Apr 16, 2025 at 05:11:11PM -0700, Suren Baghdasaryan wrote: >>> On Wed, Apr 16, 2025 at 2:41 PM Shakeel Butt wrote: >>>> >>>> On Wed, Apr 16, 2025 at 02:08:31PM -0700, Suren Baghdasaryan wrote: >>>>> On Wed, Apr 16, 2025 at 11:06 AM Usama Arif wrote: >>>>>> >>>>>> With this Kconfig option enabled, the kernel stores allocation tag references >>>>>> in the page flags by default. >>>>>> >>>>>> There are 2 reasons to introduce this: >>>>>> - As mentioned in [1], compressed tags dont have system memory overhead >>>>>> and much lower performance overhead. It would be preferrable to have this as >>>>>> the default option, and to be able to switch it at compile time. Another >>>>>> option is to just declare the static key as true by default? >>>>>> - As compressed option is the best one, it doesn't make sense to have to >>>>>> change both defconfig and command line options to enable memory >>>>>> allocation profiling. Changing commandline across a large number of services >>>>>> can result in signifcant work, which shouldn't be needed if the kernel >>>>>> defconfig needs to be changed anyways. >>>>> >>>>> The reason tag compression is not the default option is because it >>>>> works only if there are enough free bits in the page flags to store a >>>>> tag index. If you configure it to use page flags and your build does >>>>> not have enough free bits, the profiling will be disabled (see >>>>> alloc_tag_sec_init()). >>>> >>>> Is it possible to fail the build in that case i.e. check the page flags >>>> availability at build time? >>> >>> The difficulty is finding out the number of allocation tags in the >>> kernel before it gets built. Maybe there is a way to add an additional >>> post-build stage to run that check. >> >> Yeah that would be good to have. >> >>> But even then making this option >>> default and causing build failures does not seem like a good idea to >>> me but maybe I'm being too cautious? >> >> Oh my question was orthogonal to the patch. Basically some users may >> want build time guarantee for this and they can enable such >> build-failing opt-in config/check. > > Yes, that would require the post-build step to check the number of > tags vs the number of available page flag bits. I'll add it to my TODO > list but it won't be at the top, sorry :) Volunteers to help with that > would be highly appreciated. Hi Suren, A question orthogonal to the patch, the defconfig entry is defined as below: config MEM_ALLOC_PROFILING bool "Enable memory allocation profiling" default n depends on MMU depends on PROC_FS depends on !DEBUG_FORCE_WEAK_PER_CPU select CODE_TAGGING select PAGE_EXTENSION select SLAB_OBJ_EXT i.e. we select PAGE_EXTENSION even if we use compressed profiling and use page flags instead of page extension. Which means the 0.2% (8 bytes per struct page) memory overhead will still exist even when we dont need it? Should we have some defconfig option (happy with any other way) that only allows compressed profiling (otherwise nothing), so that we don't have the dependency on page extension and thus not have the overhead if we only plan to use compressed profiling? Thanks