From patchwork Fri May 31 20:53:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13682168 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 43DE7C25B75 for ; Fri, 31 May 2024 20:53:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FC846B009E; Fri, 31 May 2024 16:53:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AB996B00A0; Fri, 31 May 2024 16:53:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7730E6B00A2; Fri, 31 May 2024 16:53:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 524236B009E for ; Fri, 31 May 2024 16:53:57 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C4FCEA2E97 for ; Fri, 31 May 2024 20:53:56 +0000 (UTC) X-FDA: 82179892872.16.05F8567 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf08.hostedemail.com (Postfix) with ESMTP id 26DB2160006 for ; Fri, 31 May 2024 20:53:54 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=IEvlj2ai; spf=pass (imf08.hostedemail.com: domain of 34jhaZgYKCPUprobkYdlldib.Zljifkru-jjhsXZh.lod@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=34jhaZgYKCPUprobkYdlldib.Zljifkru-jjhsXZh.lod@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717188835; 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: references:dkim-signature; bh=dR/I60iKvQtYFc+Ix4QkX6HdwceIps2qkQq8Wc4ness=; b=XAQYwhkoW9WlZEHPFrP1QFzPJfD/nBNRXNRqa8Y2f5pVfhcz32x7/SVFbwOQibE1wKq372 c6ce56rtPgwRt1gplq2bbDOSv7WVPwbyFz4SmdRy4tXBYavFF/NGLocUdrpYq7L1FN9w2V 3HkkSOlTlxwyvCRw6eq/AHKS2/dqy6E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717188835; a=rsa-sha256; cv=none; b=OdPtTiTar3rErN+yyyuU79xF30mH/DjKWAbfvVgkyiUfhXOLYXlTwk/PpslbAnutEjeg1k 8OdXQj+hj30xQQKHqrrxh+MuPnmK2SiBlkEYYFyW08jQav99kpTy/TeZR9GOV8LGjCjZnK pzJZJIEcDYG2WjkDXohz85AsdlEOBS8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=IEvlj2ai; spf=pass (imf08.hostedemail.com: domain of 34jhaZgYKCPUprobkYdlldib.Zljifkru-jjhsXZh.lod@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=34jhaZgYKCPUprobkYdlldib.Zljifkru-jjhsXZh.lod@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-62a27e501d4so36776877b3.3 for ; Fri, 31 May 2024 13:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717188834; x=1717793634; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=dR/I60iKvQtYFc+Ix4QkX6HdwceIps2qkQq8Wc4ness=; b=IEvlj2ai5DIOMfw1y3em+AC3aWsLUYdUar0W8SpCp0eJLJGYVczUN+oRnFeGbyzxyU FtXa/i6q7zFjX1DXaYt7HQNgXaaPB15Da9WrgtuWwDGdSf5qh/G+ixOIFOB+RFRNVBjm HPUfso1ziHFLbgVGlWokg5uWI0lyxWa52ELw2D/yMZj3DW5XqG8pXfjGjAGN6IH2Ajo1 Yyl3J2cPxpONEE/K8RrcOV5mT3eDLTUCqQNzvaCX3ky/OtTNDji17iaV0keXgE0Dem// rsqbZ/Y+U1yg+r+32V+JQuS2x2hJcakqSsiLLFnraS2DZy0ums/R+DhWOOzgGtdU1yFt YLSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717188834; x=1717793634; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dR/I60iKvQtYFc+Ix4QkX6HdwceIps2qkQq8Wc4ness=; b=IMYL7KltsDzkcA3jZTV8XcDf3yNlR+ZKGzPcvGr6cNWVop6hRpTvoLyj4JjwtTp3j1 PpAO12y6i+D1MGb75C8dBYBqozRyPHGPZte3hWjT+e8E/YoQ3utU/YNwZR9egNf4YzJy khpw7EPHBwrWUZFO0mJ3n0PwlmnKOZQ2QYooHz/RpQ99tzteIkr7rv3/N7FmLu0cduAx rm77aaK/EEDYaHZTDSNhR8/vzvmEtsiRrVEjYU7upAJnCDUGzkjFwQnDLNPqxFDWFPUm qIxaHXmHHNZVCxvYcLYjW/wCTRBYJfz3Jdp769D2IOfCy0r38Zod6PGfj2wGXSZIdUFX iwqQ== X-Forwarded-Encrypted: i=1; AJvYcCU7YDGWzlLHofpEC20PcCOtQF4ARBjWFHi+nzrrZ+WLH+S40rv36vAJch9sgzg4K+4REHiykRq//HYOO2S0c1saas0= X-Gm-Message-State: AOJu0YzegNN3fBfBgtGBGatA9OB3hhZyD4EnmetqVFDN8fHmm6qxe+2F UfSivPKOVEIFo2dKNkNe+dVrIDGtFl/0vV0n/Budj0AzPItfJW6FJmb2HqCtzMiXZkLJsaOBrPR SFg== X-Google-Smtp-Source: AGHT+IE30DEKE1FmkDHyXVEgb18pk8hQIQZ3jjidV9bnSpPgD31orrHx3Ag9gA6JiXHe4ejfE1LRp0NQL5E= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:3bc3:51e0:49a8:3695]) (user=surenb job=sendgmr) by 2002:a05:690c:95:b0:627:a671:8805 with SMTP id 00721157ae682-62c796f106dmr7653617b3.3.1717188834102; Fri, 31 May 2024 13:53:54 -0700 (PDT) Date: Fri, 31 May 2024 13:53:50 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240531205350.3973009-1-surenb@google.com> Subject: [PATCH 1/1] mm: fix xyz_noprof functions calling profiled functions From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, pasha.tatashin@soleen.com, vbabka@suse.cz, keescook@chromium.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Suren Baghdasaryan X-Rspam-User: X-Stat-Signature: cnwug8rqe1xtkkqqc5d5g8e8tohtjra6 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 26DB2160006 X-HE-Tag: 1717188834-392321 X-HE-Meta: U2FsdGVkX1+nCY/GBLv/Rcaff6XMSzow6/K/cSU75HId0btjJvoSNhVstvbS3DgBcNUg441Dyb0Xfz5SBgzZti7cC41/KeUfqv5SjAKnOgUHiK2bryYCn9QsRGrrngFKUzxBzdGoXChfJymo4VhDKSGKqNXb+CLrgrn4IPgs8PfRRkivQhDGO0TRy5P/SCsRI3Y7cLY7pew/xfYAdAMgoZ2xtP2OIcfR/D8CwTGAGzyp4ptx1/3EtN2HaldRE2BlxwFwUsPyJLVqEzdfPp2HFst+mL24kDEFBUtwMEX/k/Sq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HCMRFQ3oOrYfiTqUF4a8NYpOG7BpJYAXb2DaGPcD6L12dCpoQGoN6aMr79c5uy+a1Y24ibMOIQHyPV4njhAt2E6RKyNaD3i9XFVlxNMk67fg+O02X9Cuwz+3NhCf3tQG9IKVCPcQ+URMbsyHJHNt371V5gRCgoLxwua+aeyk9a2ZyG0MfUMVkWO0p/tMrRgYLsAhr3rFSil5Av1Bd9O+1ROE7gBIx5T93t2lSCqD21x0o+Qik3tWePFbpDCMv5PhG7jzzjveQ3hA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Grepping /proc/allocinfo for "noprof" reveals several xyz_noprof functions, which means internally they are calling profiled functions. This should never happen as such calls move allocation charge from a higher level location where it should be accounted for into these lower level helpers. Fix this by replacing profiled function calls with noprof ones. Fixes: b951aaff5035 ("mm: enable page allocation tagging") Fixes: e26d8769da6d ("mempool: hook up to memory allocation profiling") Fixes: 88ae5fb755b0 ("mm: vmalloc: enable memory allocation profiling") Signed-off-by: Suren Baghdasaryan Cc: Kent Overstreet Reviewed-by: Kees Cook Acked-by: Vlastimil Babka --- mm/filemap.c | 2 +- mm/mempool.c | 2 +- mm/util.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) base-commit: 8e06d6b9274dc504af6021a8bbc2daf6713ceb20 diff --git a/mm/filemap.c b/mm/filemap.c index 9fe5c02ae92e..37061aafd191 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1000,7 +1000,7 @@ struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order) do { cpuset_mems_cookie = read_mems_allowed_begin(); n = cpuset_mem_spread_node(); - folio = __folio_alloc_node(gfp, order, n); + folio = __folio_alloc_node_noprof(gfp, order, n); } while (!folio && read_mems_allowed_retry(cpuset_mems_cookie)); return folio; diff --git a/mm/mempool.c b/mm/mempool.c index 6ece63a00acf..3223337135d0 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -273,7 +273,7 @@ mempool_t *mempool_create_node_noprof(int min_nr, mempool_alloc_t *alloc_fn, { mempool_t *pool; - pool = kzalloc_node(sizeof(*pool), gfp_mask, node_id); + pool = kmalloc_node_noprof(sizeof(*pool), gfp_mask | __GFP_ZERO, node_id); if (!pool) return NULL; diff --git a/mm/util.c b/mm/util.c index c9e519e6811f..6c3e6710e4de 100644 --- a/mm/util.c +++ b/mm/util.c @@ -705,7 +705,7 @@ void *kvrealloc_noprof(const void *p, size_t oldsize, size_t newsize, gfp_t flag if (oldsize >= newsize) return (void *)p; - newp = kvmalloc(newsize, flags); + newp = kvmalloc_noprof(newsize, flags); if (!newp) return NULL; memcpy(newp, p, oldsize); @@ -726,7 +726,7 @@ void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags) if (unlikely(check_mul_overflow(n, size, &bytes))) return NULL; - return __vmalloc(bytes, flags); + return __vmalloc_noprof(bytes, flags); } EXPORT_SYMBOL(__vmalloc_array_noprof); @@ -737,7 +737,7 @@ EXPORT_SYMBOL(__vmalloc_array_noprof); */ void *vmalloc_array_noprof(size_t n, size_t size) { - return __vmalloc_array(n, size, GFP_KERNEL); + return __vmalloc_array_noprof(n, size, GFP_KERNEL); } EXPORT_SYMBOL(vmalloc_array_noprof); @@ -749,7 +749,7 @@ EXPORT_SYMBOL(vmalloc_array_noprof); */ void *__vcalloc_noprof(size_t n, size_t size, gfp_t flags) { - return __vmalloc_array(n, size, flags | __GFP_ZERO); + return __vmalloc_array_noprof(n, size, flags | __GFP_ZERO); } EXPORT_SYMBOL(__vcalloc_noprof); @@ -760,7 +760,7 @@ EXPORT_SYMBOL(__vcalloc_noprof); */ void *vcalloc_noprof(size_t n, size_t size) { - return __vmalloc_array(n, size, GFP_KERNEL | __GFP_ZERO); + return __vmalloc_array_noprof(n, size, GFP_KERNEL | __GFP_ZERO); } EXPORT_SYMBOL(vcalloc_noprof);