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 A1417C3ABC3 for ; Mon, 12 May 2025 21:02:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D9D86B000A; Mon, 12 May 2025 17:02:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 986D26B0082; Mon, 12 May 2025 17:02:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8740B6B0083; Mon, 12 May 2025 17:02:21 -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 6BD566B000A for ; Mon, 12 May 2025 17:02:21 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 89E78120A50 for ; Mon, 12 May 2025 21:02:22 +0000 (UTC) X-FDA: 83435478924.20.B9C05D3 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf23.hostedemail.com (Postfix) with ESMTP id 8323A14000F for ; Mon, 12 May 2025 21:02:20 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=purestorage.com header.s=google2022 header.b=KtBKOqt5; spf=pass (imf23.hostedemail.com: domain of cachen@purestorage.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=cachen@purestorage.com; dmarc=pass (policy=reject) header.from=purestorage.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747083740; 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=zm3iuUhSuiltfQuiz8oLCXU1QbIlFKGh5KKkHYJsegE=; b=pwc//iNqeGrwo4panH7vSBeyjoDbf8PkIaDdw7z3ov0G7EiuNUVyWZWREBx9hZzrHFGY6S Mo5uUAT82rU4GIFsdIZ+LqVdDKOtQcj1+2ShJMCNYLL2FfWCpwEESMKMx7XY0scHHyno6h zZ6/WPs+21fEFyuTrtQyXCPPEvBXd0Q= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=purestorage.com header.s=google2022 header.b=KtBKOqt5; spf=pass (imf23.hostedemail.com: domain of cachen@purestorage.com designates 209.85.210.174 as permitted sender) smtp.mailfrom=cachen@purestorage.com; dmarc=pass (policy=reject) header.from=purestorage.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747083740; a=rsa-sha256; cv=none; b=2Oz991ChDBebn9P4xT+/fkANXZ5xJ1wzZs1bEpbuqMVzSO//s0sfUKa/smBhNvUPZJjeVn Fat/r2aS6AmXaLO8AeBnb6fFwFEtJHW0qFSrRLuVqmHh1qtxlfqX/87nMDVZHV52RdwRC6 H3yuvUNNZdikV1EB59l1KUbvdVlnhAU= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7390294782bso712610b3a.0 for ; Mon, 12 May 2025 14:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1747083739; x=1747688539; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zm3iuUhSuiltfQuiz8oLCXU1QbIlFKGh5KKkHYJsegE=; b=KtBKOqt5BaJUXm96mRBGWKfh0DczjDa7yrUFDs5csfFfrzEqP4HoHctGqO+E4IGlmD SMe9abmcklnd/g9x0u2/sPazHBmHN/69rdNyORH79tGSuvZtoosBc2fsQG8a2XZXeD6v Tk++3xoUJxbjfwJNolfdGSmfmuEmnI4zFjT1e2VCjqdV7RsbLeKkAI7VzVTcvbeDNDHu RymCiDUGQhH1DqiZAejkfQaNwfblAvzU/C1N+c1ykYia4oY+CMhKVlcDCDxKQZoYuTO6 zkGa/rbN4ReraEZFicuBFTp8cxEQLi9K+17nu5y86uiadPfWPyqfTSnIv9D1EDGBfsn4 aMOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747083739; x=1747688539; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zm3iuUhSuiltfQuiz8oLCXU1QbIlFKGh5KKkHYJsegE=; b=k8qdJkHtE3rt1W1uHv+o9+6AM2k8+p3I9MSQQ+Xmp1Z1DFnNca+hi0ZVQIdjLgCsUU 7M3mqKm58IKfKb2OZhwDOzGVJpfRmV/9bwVRBGWOiE5BDnwz0fwgCQcg1wMpDiwb4Zm8 T3FRck+uS8CQ+/UYRYQgRk3PqgOCW5uJIllz4aSRwUi5brkja0mnIvX/vsnNtIo2UL7t Utp82j0Gwt2L8+GsCEm9qz2H7xhymOARGlDVlw7L9prGIbxmOUIKxI/TIe1IL1ju8sHa fJ+jk8GFkZnIYjLpquLf3GieIwsG0NX5o7yHvybZhc3a9UF/ahMcfv3R/PXmPq+hMVoN lC2A== X-Gm-Message-State: AOJu0YxfcgtG5Xq9xvqiDMxr7zZB6hihDGNgCzVCuYRf4MV5q6UUNSVE M/L0A2KjKGeBvWdB6zOd1v6a1OBys2lAgDuIuZdP16aVPcxMpLmmReoOHCKvQXQHHjx435W5qwn GyE+Qg1z+iR6ztzPFIyf8jZv2IrFZBenU9mJqjTw1rlms1Mlvt/0= X-Gm-Gg: ASbGnctrZ3Wu16mrZUZoo1ccW9GuQQXIGXfehDiyE0WPYRwpFdvvS4Fvf8nJMnXIvh8 rRHWNY2tZbwJCOCnBYZarBdGjySGEY+fFSYwczKvh0VWgQW8ZaGR/HwT8TNoTX7AOvW1uzkxKD7 IaKjbVSB4azLMJi+8WI30LHTWEpzJANfDG X-Google-Smtp-Source: AGHT+IEPYz3vP3OKJlx5XmFS4OKdcTb4ku5uQ85HGV8LjpnWlA8GNP3Obm4zfZdncehaVuX0a49AZHKKZMirabrUAKg= X-Received: by 2002:a17:90b:3b86:b0:2ff:7970:d2b6 with SMTP id 98e67ed59e1d1-30c3d6517a7mr8747668a91.5.1747083739149; Mon, 12 May 2025 14:02:19 -0700 (PDT) MIME-Version: 1.0 References: <20250512194249.14501-1-cachen@purestorage.com> In-Reply-To: From: Casey Chen Date: Mon, 12 May 2025 14:02:08 -0700 X-Gm-Features: AX0GCFs0W974lqH_tYg5eZek6SnUtwJOmnBxMccyP4D0G6W0rat2b-nAEqQs0f8 Message-ID: Subject: Re: [PATCH v3] alloc_tag: check mem_profiling_support in alloc_tag_init To: Suren Baghdasaryan Cc: linux-mm@kvack.org, kent.overstreet@linux.dev, yzhong@purestorage.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 8323A14000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: yrz64xzjgot5rgkom1pxqgyn3c8383cn X-HE-Tag: 1747083740-749465 X-HE-Meta: U2FsdGVkX1/CWgRYM2Ero0MBeFd/mHCoqxXPeGly0x5dyqoEoyIHpbd+uWiI02V9Ss/pBwndoATj5uWvrB28sONa54c4mjgedkAAnHCdUoGv/oGtIW2+ANLwH2Ccrb0rsZigLphBYOnY8q3d/fDV7zilohqA2CWxBs8mJKYwztyUQhDLTsxCpfsPdhVoXRKJ0laXCvZRMQSM61abrZWtEh6+zIrHuoVmtGkK6n9pIf8d4Gi1HAFQirqt4rJd5w0FEMcBHOAcG/xUA8e7kjJVBdYEVtUGpRIuByMtocc6eDf3zSLKKUQ4cKTuOmFNsj2Wr9q2k1vVxnZqnedMHSLMYd+HNG5lErEZReOHW73/8k6NUzqXVU6eQY7t3euv9tScaszUjyZKD49PYMfvpOlfIZ4YhabKU882OinePCYNqvZvDBjGj1G/UO3XKHVg+aEfBKYzm+tDnepkqyNHbE3EuV/zvnUEkAr1P2rYad5zDPwgBiVCZZIq1GrM/eX8Am/ytJLC5zyZ9VXh+XzeHXYHKKK4B/wa1V3OTnq+JLN2WFH0fmJlUwYUqMlI1ZCuhTtcObmgzpl+l9+SqE1eg8pOpO9/0GJW1IdjmeH4z65NqcEtmmjqC5xIrBoo0Xd/PmhZQQ9Jriuz59A75jpVSXQppPPrigfMjmQQVuivoSDOsvIJ326BBJ4nC4NhLGoe9PQ7VDYlY0H3R0F4VBZLVcYm4Xqil0AvGPchzhalQTU2HGVplyzQv9R6ktJEa25Mes21hiiWvG5K9oKBmSjM0/zaTI1As3bQXFr4Rs+128WmfcrCpaH792Trqq0CN/NTJmUAD6QS4cY/Y5U1DMnOqdg+otJdaOmRuRLdxq+SmgmlI8t5ajFDFK+guVxwr9MrVDgNkgyP2//El5BEFetI4NERN5xOk72zLH7mGWc+0mgVij9vP0mftiur5ja4Wh++9zDP1BPB1DiqXqjV5QgzayY dAAGvhFD YevziRLqK4gfk06GZU2GR+MteuCEUoGhaRNwToNXYuilkKd4DRTfW05m5SwrCS0FrPkob7f6Rbi97WMgIaWlGuxgRz1V8r/PaGoiUCtGYcB0VGpiPXzDm3NdaubMlvRWeg39O1sSuYD2GJ06fhkIbplmaXSzE3W0/+AO+OQuR8+4/Y4GlzEZxRTLnfxzb04NVLkMY+ZcClJvYYZNQmtFi3yYtEdCsy+5IbwxWDz6znNo91ED+zai1x3v5N4fIVeYIr27cSJsOedCoBXHe/eOj5VSgdMZL7ZO+zSAULyFQxUlDFSFwTiBPJTVZGlBF/x+Ja993m4g1pCjPoAjoz+0npO1D/A== 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 Mon, May 12, 2025 at 1:53=E2=80=AFPM Suren Baghdasaryan wrote: > > On Mon, May 12, 2025 at 12:42=E2=80=AFPM Casey Chen wrote: > > > > If mem_profiling_support is false, for example by > > sysctl.vm.mem_profiling=3Dnever, alloc_tag_init should skip > > module tags allocation, codetag type registration and > > procfs init. > > > > Signed-off-by: Casey Chen > > Reviewed-by: Yuanyuan Zhong > > --- > > lib/alloc_tag.c | 34 +++++++++++++++++++--------------- > > 1 file changed, 19 insertions(+), 15 deletions(-) > > > > diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c > > index 25ecc1334b67..7c798778669c 100644 > > --- a/lib/alloc_tag.c > > +++ b/lib/alloc_tag.c > > @@ -244,17 +244,6 @@ static void shutdown_mem_profiling(bool remove_fil= e) > > mem_profiling_support =3D false; > > } > > > > -static void __init procfs_init(void) > > -{ > > - if (!mem_profiling_support) > > - return; > > - > > - if (!proc_create_seq(ALLOCINFO_FILE_NAME, 0400, NULL, &allocinf= o_seq_op)) { > > - pr_err("Failed to create %s file\n", ALLOCINFO_FILE_NAM= E); > > - shutdown_mem_profiling(false); > > - } > > -} > > - > > void __init alloc_tag_sec_init(void) > > { > > struct alloc_tag *last_codetag; > > @@ -762,19 +751,34 @@ static int __init alloc_tag_init(void) > > }; > > int res; > > > > + sysctl_init(); > > + > > + if (!mem_profiling_support) { > > + pr_info("Memory allocation profiling is not supported!\= n"); > > + return 0; > > + } > > + > > + if (!proc_create_seq(ALLOCINFO_FILE_NAME, 0400, NULL, &allocinf= o_seq_op)) { > > I suggest keeping file creation as the last step so that we don't have > to remove it if later steps fail. > If the file creation is the last step, how could it clean up codetag type registration ? As we miss codetag unregistration function, I think codetag type registration should be the last step. > > + pr_err("Failed to create %s file\n", ALLOCINFO_FILE_NAM= E); > > + shutdown_mem_profiling(false); > > + return -EAGAIN; > > Why EAGAIN? I would just let it fall through returning 0 (after moving > this to the end as I suggested in my previous comment). > return 0 is fine to me if this fails. EAGAIN sounds fine too. > > + } > > + > > res =3D alloc_mod_tags_mem(); > > - if (res) > > + if (res) { > > + pr_err("Failed to allocate module tags\n"); > > The error message is a bit misleading here since we are not allocating > module tags but reserving virtual space for them. Maybe: > "Failed to reserve address space for module tags" > Sounds good! > > + shutdown_mem_profiling(true); > > return res; > > + } > > > > alloc_tag_cttype =3D codetag_register_type(&desc); > > if (IS_ERR(alloc_tag_cttype)) { > > + pr_err("Failed to register codetag type with desc %s\n"= , desc.section); > > pr_err("Allocation tags registration failed, errno =3D %d\n", ret); > Sounds good too. > > free_mod_tags_mem(); > > + shutdown_mem_profiling(true); > > return PTR_ERR(alloc_tag_cttype); > > } > > > > - sysctl_init(); > > - procfs_init(); > > - > > return 0; > > } > > module_init(alloc_tag_init); > > -- > > 2.49.0 > >