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 C0DD4C369C9 for ; Thu, 17 Apr 2025 18:35:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 572E42800CC; Thu, 17 Apr 2025 14:35:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FA602800D1; Thu, 17 Apr 2025 14:35:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39C722800CC; Thu, 17 Apr 2025 14:35:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 51EA76B00A2 for ; Thu, 17 Apr 2025 14:35:43 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DB469C033F for ; Thu, 17 Apr 2025 18:35:44 +0000 (UTC) X-FDA: 83344389408.14.A44FB12 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by imf09.hostedemail.com (Postfix) with ESMTP id D41BE140008 for ; Thu, 17 Apr 2025 18:35:42 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jInDLGYT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744914942; a=rsa-sha256; cv=none; b=AwMxX4+8rhMPbrF3/zZotwrNqi+1+OabWPDM7A5j9Oz/JFKHPXuTfCe+P4y2eMscqrsW3f ICdVwqozAIYF2rbYBuWlQ1hW3sWCY7AbFny8LstP0WEq4jxL9BJIKJa0Bhm5W5VSKjVw0X k49uXDiOlA6dHIyGNkTfSF7Q9Nx1v/I= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jInDLGYT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744914942; 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=zDWy0FSBv295dE0TZfCJ23cymB+rWP6UWZ/2MeAOnfE=; b=g+RMU8p3nazvtuAHPMGZfyzFuc9hP54dmVHpAxV+UEfol9weTA2x3ebKhe96d8rwB5YKRW UA7QaolRsdXh+QH+vvyMA21TaZlr0v8Yz+C8UWDQ62y4pN6/1OHKJK31N7d2RJ750+GSkQ gRAsGoaZ0j6ElWCZ0t+z87FH9s+dxuA= Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-39129fc51f8so1116538f8f.0 for ; Thu, 17 Apr 2025 11:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744914941; x=1745519741; darn=kvack.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=zDWy0FSBv295dE0TZfCJ23cymB+rWP6UWZ/2MeAOnfE=; b=jInDLGYTpCojjl22AZFT11l98c8V7iJ9Qd1dlgWtciY5lXV47HwJVSBUcHaHlHPecX e10r/5tL/tc3fnXHQareY635PCiRFagbUeF/JedUDHtHJE6dwJTxfMCFjsIE0z6QapsR 3KX+4pQ0zizKfySm6tC6kydhXALwiw9z9SBFMwbRSxMkWZfLZdZaBiBpISLMbVZ9MeSO sYqPW9bSOG7Zsobm5GKLriBgS6FvqY2OiNiSx5+7nscYX7F5lBQuaKKpVLmJ3p2q0cGj gZ+StQGUCXgrFh2QILAE+KQfvG+wUmaCVu0jN+MM6y82ehJdL5Zt7VzSeaAxVo6i6KUl AzhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744914941; x=1745519741; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zDWy0FSBv295dE0TZfCJ23cymB+rWP6UWZ/2MeAOnfE=; b=LQ3Ua0VUCuyAf7rY6A/yH2pPqMptO4LLTquJsQGZ93DxwJ9EF2VxMFKwo7OWLVz6rJ Znd7yKzZwFHWloEW8khziAoJN/58PVMDeru/kqfqcSjt6TqcASeqGhWGijmwSYGLzWaR z7BbrzOr2GTcRoVbSDZsaHJLEnxA5gbT+jnlDBuWseeNsYfKSZXW0mXowqiI+GmWw0QL w43crW1Pd25VSCla0JMZcjwKbQjv+KgscyrQF36djMWenunQii/yVw7nxqbt2XfVZLTQ xRY+IKARyBixQd55B/lMoF8rfhAgY11SjVdK6NMnafWqpqYGQGXH49iAMSXf7doQ6eW/ 9bkA== X-Forwarded-Encrypted: i=1; AJvYcCWWMhbfIG8YVnh6F/iRkjrgMVg7AX/7ikWWQBgQjQnGfxCYwtbGos9Rkh1oJRZ19iZL8bZw1YxWJg==@kvack.org X-Gm-Message-State: AOJu0YzHKvJ3jVL74OBmsggsoa67XujLK7fLEOC07tpYnCSPm3DXxr6q 9+r4hn1P+fMFkCDarjToSSmhIzz8oGSRQ3+z/uxvG3vpFcRO2KdP X-Gm-Gg: ASbGncuTO+vfamb60T6VDcAj7Ky6EKaAkgXX0rAfUtAm2ojVslONtezI5OZ9bSjuKBR AgBAd49nv8T4gNKWhNq1uIu/Fp2Z7Cul+c4dNTbVH6s3iYZ0noxXXY9kdIS7Xb1ZVnyy92rdC72 pl2rZMChNMfl2JnX1Suh5Np9QxpMOk9wVxQpi59wYFnRtIogyVinirmrOeyWSGnSTPd9gdLYWg+ 5gYu/cq3eHFZbkfWdxgq4XW8xJx7VQ6JE95NOQ6W1apHaHp6vEq1g0D8Ij8BCJyNYTAEW+qxIBH 6rkJ2RMqphdJiyRpOhtpSLfuaRIaUEuZdAq5CQGr96NxrW/KSQbjYRJ14qurIzyBnvqR4NhiBsi xsf403pBkGU+q1PJYNCcUoXlJ3FJ92PCbTA== X-Google-Smtp-Source: AGHT+IH5dwT9AbAtaTlj5uxeVfdRvRULPw9LQYqbZFneLGifWjlBTCmEa1W+LiPp8Bep12yajdYiYg== X-Received: by 2002:a5d:584b:0:b0:394:ef93:9afc with SMTP id ffacd0b85a97d-39efba4610emr23622f8f.18.1744914940958; Thu, 17 Apr 2025 11:35:40 -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-4406abbe298sm293295e9.3.2025.04.17.11.35.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Apr 2025 11:35:40 -0700 (PDT) Message-ID: <33632210-6de3-445b-8f9c-d0fbcf3deab2@gmail.com> Date: Thu, 17 Apr 2025 19:35:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] alloc_tag: introduce Kconfig option for default compressed profiling From: Usama Arif 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> <25ac1d9c-c7e4-4dcf-b297-254fa51c6f2a@gmail.com> Content-Language: en-US In-Reply-To: <25ac1d9c-c7e4-4dcf-b297-254fa51c6f2a@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D41BE140008 X-Stat-Signature: s3aa3wqfxft3ukc6md8s734ix67yje6f X-HE-Tag: 1744914942-21697 X-HE-Meta: U2FsdGVkX18B2SZeDZLBs8FOZS87i8fkZvybB4qSb5jG7LEg72GmgCgXXqm/yy2Te5bWaVCo/x1eIr2Wp4cVK+vL6tfEgVK9UzNzjYvmI+Z0iBQQucoiMMSEhs0k61IusmFrv7hCLWq43DDbuLeNYythLWlj3DlcbVmlAXAlD00Uu6xhnl1E0TS6k55dDRblAG1jhb14Z4V2fBMronM13iZG/arp49NvF11Psp6QDzTj2Z4P/YsSpUJ964mCYm8xoPWj/9p2sz/SEPNLpfcj3NIOvg5FWR+MHakWxHxrOP357O8059M5harxFJ/xU9ShItYattvZUhsXQruLzu5JbPa1TByLMNES6hce9evW6HXJcIxlkbtaI1nMtKhvs55EdTMBlIYox//va0kRI2POXK+oAG6xCt9nk02+fQX/jt/PEgj6KlrEENSt5g3q/QGgGs7IMjX4dz+EcPo1J/Ld3aA/W22XpXGWeXF+mqzsrByoOWMHtVMr0okClppfBNnJ0g3ThcxfsRQpiPA9se2Gj1an9tZyqGRkOxUhJwc7oMVwxtKrDF2R5E4RvUPK6fzLbtv5he7Jra+2mkiKNSDeccZTY3gmgBJsrC83KCKR7SwFlDwUmML/f+ISisq6Qxmb2UT4LHOgbMWVGkx9HnehEbX5zvSlGCKMxqaHqVkRK4XAlAYxobn+mAcCVShUckkAyeoccrv/NCeQTNSXkGAA/GbwtxtQdenXRVlMDDRgZV0/rAY/4BHd9gW+Ivdsxkc6D/23Zi4BZT05k6nGg1VTksgrmygfTFS9DWnm9jOoRTNR0zTUSaJf3JcqoPW8hnSzo8ITceijAOHJC3HHDuArHfhsFayT4EEGssd73FY3YusCGO9UWCUV3LZOWayr32FlbzI8XyoAFgxBZnMKUMG9KMXHySS12Bj1fsG+eQNJRHVFJn3+XMuz0gDnxOqMEWDAYxR6kJd2LzvEjL7pHje 3H+r2b+c vFSK8xKwMY1mTE+qCVcPdJfpzv83sEFDBnB2FP/nC7LE7pvVI8zu2UeH+b3BTAL/0cmxasKscmlkHeqDJF7IN6WjFvSG3TK7KlSiNGQTzUMVul4gaS7p1E5v4D7ABQv3N7tlQlrSabFa89xgdTNt+a7PtTMsK3YqN9NWEjNnA6EpKG+8arBEiYxc3JINHkZSsn0witKrt1FeLbOu1nDQMARbQIY5jwh6FCJ/UXzfj2Cy+You+rBZKpdZWWRoxXS9CMo4Hs/H3Pw+Oox+sgvvBAkxTpLauao+rlpzGlNtEWatuE0HpPwYAB1XqPAmlll+PnSg+J/QOxGNzrGqWufcrwE1UMeWobvm8DkWKD6jOTTX6KQ83lYnMPI69X4r/pam8tABomZlB+OJIr/WP2UalatdUwgygw6easib9EmW8k13EnLhbbLj46uqSFjcNAdaO5c9leSUu3zv2o3nOiq2WOpOUTvk3i73lX76jyIZUCj+2aq3uisp9TOKJjtpffOFkFF8sS4u0fYtXaSLyFLBPsdiNbA== 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: List-Subscribe: List-Unsubscribe: On 17/04/2025 18:50, Usama Arif wrote: > > > 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 Johannes pointed out the .need function of page_alloc_tagging_ops, i.e. need_page_alloc_tagging, so page extensions wouldn't be enabled and hopefully there is no memory overhead when mem_profiling_compressed is true. Let me know if my understanding is wrong. And sorry for the noise!