From patchwork Mon Aug 19 15:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13768489 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 A26ABC3DA4A for ; Mon, 19 Aug 2024 15:15:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EBDC6B008A; Mon, 19 Aug 2024 11:15:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39D716B008C; Mon, 19 Aug 2024 11:15:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EFB06B0092; Mon, 19 Aug 2024 11:15:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F1D866B008C for ; Mon, 19 Aug 2024 11:15:21 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A79E141376 for ; Mon, 19 Aug 2024 15:15:21 +0000 (UTC) X-FDA: 82469343642.12.3A64F81 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf07.hostedemail.com (Postfix) with ESMTP id D34B740015 for ; Mon, 19 Aug 2024 15:15:19 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tJtqginb; spf=pass (imf07.hostedemail.com: domain of 3hmHDZgYKCJMFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3hmHDZgYKCJMFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@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=1724080504; 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=VNxQmk8ltcvVRdy69Ay4z75/w4T2K+JdAEqULautUD8=; b=7zhAr1Pdlr1QcIxeJmO+8ZC872kot0FPkKbXq+c9CagAe1QoZty8wsW7Fv+rrNVqHGhvUX TuJXMvezTg+ABmHm0aLnMD6OocK6nXWGB3ByZqs4JLLNleMa1UfObc00Lmu59CbZYHboeH anWyvYxRI54StRCNfZ9l/s6EDrA1fvs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tJtqginb; spf=pass (imf07.hostedemail.com: domain of 3hmHDZgYKCJMFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3hmHDZgYKCJMFHE1Ay3BB381.zB985AHK-997Ixz7.BE3@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724080504; a=rsa-sha256; cv=none; b=ZRXg6M9E3Cg/BcVPaJR+hTpZVy614FDJgOPLgzRDgEPnGc0kTD55IAmSJ53vcQqmNgBy8u dALEYByML+eMlVyarHGLRtr4aO7paaD3iQsqK0nFQ22B6JR3B+1h8aBvSqHAYc5TAZbVcU mc5C1OZv+Wl+rTBWl7cGJMj91LFKhOc= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6ad660add0fso56110637b3.0 for ; Mon, 19 Aug 2024 08:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724080519; x=1724685319; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=VNxQmk8ltcvVRdy69Ay4z75/w4T2K+JdAEqULautUD8=; b=tJtqginbwzV/8hyqK9RM/a0lFL2oZtE+ANAqwXvHRfeJPnulYPorurSqgIWxDc493K WZaNQe8ILQsZE0Oqx4W926V/rdYaFrLu1MLT+vsO7K4YssqwOLuC5GKijffBmE3OSofQ Y+R8kj9FyEmERwzxR6Id8XPkrd3EFF8XTdXh8yMGvd9nXuhmFRQhKM2q5mS3y2DUt9dT +N8Q/sUA1vro5VyeroNklRC6jbUPWagQ6yY0+wGuiUgOB4AxCRc/HpzSvhzfJ+a2lBQI 6ZxD4sofv/P2Vz0w51RawPpSpDhNryMa4G9t8lGja5Zc4Rw5Ies8durwwSgnJjUCpvsg Z4RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724080519; x=1724685319; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VNxQmk8ltcvVRdy69Ay4z75/w4T2K+JdAEqULautUD8=; b=FQ5HRXkhfGCdef03oY7hGaKESFWVkCkfiCRrPwyWa/qrw2hhzoDFr/e0iHlKKSwRRk NUUOhGHn8e/eZvFoTZBuvh98czvI7LqvPn4HjFqwBvTRy4cXAT9NxYZule0hNKiow41K OK+A0CgHlRF6Z4Oz7umvtH+1rtj5ZnJyJRj6H1UdIxGmfmT5ZmR2/6id7mn9LHYz775a +25D5eqygw5NCIhywRKceFyp8GM0qBrhtuAiZGW/UMlBv/05to1FTNwJ+K4qOeU8Fz7y 1ryPwU6Z8TzMGk2MkCDM5m5DxDB2LGwbtvM1LEvlTvSPtSnjCA9vF6rQaHVDKgeksmIT N+Wg== X-Forwarded-Encrypted: i=1; AJvYcCU1qnokCsXYrOinwtp6yvzV8kU3icwfNgwU+MOeEvbffI8jt3ENcI52zP1bJuPEdjtkf965+LnEtQ==@kvack.org X-Gm-Message-State: AOJu0Yxl0IhbZEq6UHBvjfoRbvYyKtrgSB4dZgMwNjX4xGWUXirsOThS QzyPqTYMEwK5wQKbhAve+AXT3hTznWrtsWqOWH/PT8UZ3eQ5ihctUBT2MzLHBCM4HNUynnbctQF nEg== X-Google-Smtp-Source: AGHT+IFc3XJvlFR9abCJBzx6LfnqtUZrq0wbNXmeGLgIyv9XIwJOTdcKULoLpjDTZrzYGsBBSDXaDMNiqLo= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:5aea:cf26:50f4:76db]) (user=surenb job=sendgmr) by 2002:a05:690c:b8e:b0:648:2f1d:1329 with SMTP id 00721157ae682-6b1d38cac51mr8818697b3.1.1724080518814; Mon, 19 Aug 2024 08:15:18 -0700 (PDT) Date: Mon, 19 Aug 2024 08:15:08 -0700 In-Reply-To: <20240819151512.2363698-1-surenb@google.com> Mime-Version: 1.0 References: <20240819151512.2363698-1-surenb@google.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog Message-ID: <20240819151512.2363698-3-surenb@google.com> Subject: [PATCH 2/5] alloc_tag: eliminate alloc_tag_ref_set From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, corbet@lwn.net, arnd@arndb.de, mcgrof@kernel.org, rppt@kernel.org, paulmck@kernel.org, thuth@redhat.com, tglx@linutronix.de, bp@alien8.de, xiongwei.song@windriver.com, ardb@kernel.org, david@redhat.com, vbabka@suse.cz, mhocko@suse.com, hannes@cmpxchg.org, roman.gushchin@linux.dev, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, dennis@kernel.org, jhubbard@nvidia.com, yuzhao@google.com, vvvvvv@google.com, rostedt@goodmis.org, iamjoonsoo.kim@lge.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kernel-team@android.com, surenb@google.com X-Rspam-User: X-Stat-Signature: sbpgwntaiwt8hh41675fx9pf7o4xy3tm X-Rspamd-Queue-Id: D34B740015 X-Rspamd-Server: rspam11 X-HE-Tag: 1724080519-299301 X-HE-Meta: U2FsdGVkX1/WTEGHRkwd5326eqxP2GWQ9d3wjRfSbnf5mCwPle1rrsjgyewUDc1lZGfUaaX+bWHQEb0mSolfK1qvipau6FAsiKfNSFFk6tDMENdXVmLhenY6fg0jHMwFCBeLENtGdy/KgGsIUt+HFlJG8WzVv0Z4A3cMzDq+SdYFIUW6ZdI/kWJoXEGqYDqI7ECubRfFmqLorb0xtrz+mqMIN5lALabTTiKyyKc5aJ6OJDxQVvzI6HTFfnfltxl9wvk/wkevMxeQlVljbCPzX3CcECsxtCKBPmkBV4LiWKiTnXFaGcSJGaMLFBePF4kr8gZ2aGssn25KDEHtWGwA901mtcWu5bYwooaM0ko1izra02Ok+dt96Fqztbkl56FyUkeGTKeZlGjLZGMVy3e5eGhmgwFYSd8K7ZTh3DYDon5jFEgsXE6u0w4O7TktM8yKkQ08oL/wRtH7QPuDIFmWo+6kUwrXaKDfGHVAuc2CsR6GOKxpA7nSe/MifUJnSFXwf0MduOqEULY3/8DeR/XD5yRB2+MQ3dbBI/JtlYraiUU5vTqcNP9QRii9Ti5piuLltnVKg4+QCi6nIHNmKHnGYE+CZxW4bHClHEBFd8FyNwnnnFoAki0qgLx1rNfvdw+2jwH1xIpC6eGTo5UeR/B0A35mvCNhmHVBrhMowTrVo4K5WeydaP6Ak91CafiBhHA+tif5sdDGmBAHwEAzL0zmDXF0ILpRr5C+icj35dJ9DI8x9hf4Zesp1coH95ovY8sXcLoZnPbfffjn7hjvxGDp6tRrnZk/WhPcB+MDxm5yyJoucuzWs6xdUVN1tXaWiZBxJwnaAYO5LrGqK4x/zs+wPnndGlAsuVT77IhH64rjvNf4eXlbmmKDNoHtH3SA9Osp6AEVqdwTPupFqDYkblJl58Gl4QE8P7F/XJjq9wtwapz+FyzhXtSiFruXuLz+xJg4rjQZl6IfL59/l1sZVn2 JEllruMq iWrNWscY5fuS8JTSU80NigIdPY361iH66hDUzyT5f2TPM5NT9lSakzROQxfiy+WcWlCd0HuP/lR4lWuwS+n08xJq68ebVgb+nsnKMxrX+f+JAAcjEhCSqXALr17PzY6HCquMmuEwyueqR/31K7tviNghQLFvf+Uhceid0fxM7MIhcEhQ8yaMUjXzAZh1UW6yXAlRunhaPi7Y4Jb4SEwkOuaSbBtaNNrwDTuUOVlVct5UsslY3e4cUxNj9L/y9GdZ9RD/i0YdXpPPSPs3UazUZjiiKddKRT6CZ8mmCjRdZvjcI1H+IMB1/3GshLZLZpcUtaBnlVnp5BHFo2FsDKcfNERt1VIvE+bQ9P8jpIxl1SaXijEUnBExzmH8D7m8UGig8wV+ztY1IJc2fJP066IuLNM4dyHIoQgfQrXgjW9yWThAeUPXbl+WjQWkNFB7gwJtYLaidOE9BHF1wpA4OtMkpjYUMaeH938qtjXdqgswBSOsks+12cda8hAWVGEo+bxWikSiKpfHahZrDegzA3vgehnLMfEHXNMLK7z6jxqWGATA5d5SRlZmeVogRNrgB40rTCjUmfvObSHhIZSF74Dig0nx13OutUYjmlKvV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To simplify further refactoring, open-code the only two callers of alloc_tag_ref_set(). Signed-off-by: Suren Baghdasaryan --- include/linux/alloc_tag.h | 25 ++----------------------- include/linux/pgalloc_tag.h | 12 +++++++++++- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h index 99cbc7f086ad..21e3098220e3 100644 --- a/include/linux/alloc_tag.h +++ b/include/linux/alloc_tag.h @@ -143,36 +143,15 @@ static inline void alloc_tag_add_check(union codetag_ref *ref, struct alloc_tag static inline void alloc_tag_sub_check(union codetag_ref *ref) {} #endif -/* Caller should verify both ref and tag to be valid */ -static inline void __alloc_tag_ref_set(union codetag_ref *ref, struct alloc_tag *tag) -{ - ref->ct = &tag->ct; - /* - * We need in increment the call counter every time we have a new - * allocation or when we split a large allocation into smaller ones. - * Each new reference for every sub-allocation needs to increment call - * counter because when we free each part the counter will be decremented. - */ - this_cpu_inc(tag->counters->calls); -} - -static inline void alloc_tag_ref_set(union codetag_ref *ref, struct alloc_tag *tag) -{ - alloc_tag_add_check(ref, tag); - if (!ref || !tag) - return; - - __alloc_tag_ref_set(ref, tag); -} - static inline void alloc_tag_add(union codetag_ref *ref, struct alloc_tag *tag, size_t bytes) { alloc_tag_add_check(ref, tag); if (!ref || !tag) return; - __alloc_tag_ref_set(ref, tag); + ref->ct = &tag->ct; this_cpu_add(tag->counters->bytes, bytes); + this_cpu_inc(tag->counters->calls); } static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes) diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h index 207f0c83c8e9..244a328dff62 100644 --- a/include/linux/pgalloc_tag.h +++ b/include/linux/pgalloc_tag.h @@ -103,7 +103,17 @@ static inline void pgalloc_tag_split(struct page *page, unsigned int nr) page_ext = page_ext_next(page_ext); for (i = 1; i < nr; i++) { /* Set new reference to point to the original tag */ - alloc_tag_ref_set(codetag_ref_from_page_ext(page_ext), tag); + ref = codetag_ref_from_page_ext(page_ext); + alloc_tag_add_check(ref, tag); + if (ref) { + ref->ct = &tag->ct; + /* + * We need in increment the call counter every time we split a + * large allocation into smaller ones because when we free each + * part the counter will be decremented. + */ + this_cpu_inc(tag->counters->calls); + } page_ext = page_ext_next(page_ext); } out: