From patchwork Fri Aug 16 10:32:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13765887 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 B570DC3DA4A for ; Fri, 16 Aug 2024 10:33:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28B686B0309; Fri, 16 Aug 2024 06:33:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23BB36B030A; Fri, 16 Aug 2024 06:33:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1035C6B030B; Fri, 16 Aug 2024 06:33:02 -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 E75CC6B0309 for ; Fri, 16 Aug 2024 06:33:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 936C7141A39 for ; Fri, 16 Aug 2024 10:33:01 +0000 (UTC) X-FDA: 82457745762.22.C34443B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id B460C180026 for ; Fri, 16 Aug 2024 10:32:59 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Kr/ilcno"; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723804321; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=Fs9xcyJg7s52rkpgu5pEX5FPQ0ebM/lCKmDb5KCxkoU=; b=psQ+y2iN9T6FJOUZESKLbRf20ei07vgadCss8YySpxIHHzDYK7SJ5YS0L/PnxN9ArO7RzU 6oX/SKWsMOgvE7+eRxBO8349drDfB7r/4biImIor7ZOoGPRe91mKG/ngXJDAdX3FuOBVjJ NvKAjeikB6SU2V3RIEyaZ1NiwWXr5+w= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Kr/ilcno"; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723804321; a=rsa-sha256; cv=none; b=FFbJ7Rhs3E2KYPviwYF9URpz8LsMxf1LuFV0rOVEDCkgO2+sZ5nG3uINDybStCq88ubtHu wkLYGvEginZ7mPfOPW+E+koDE/HX7IYRrtDSnvtF7QI79ph5oiKKxQc/4NlJM2GuB25l86 S3rtsIL7dXpuQ869SbfNNQ62eBH9q5k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723804379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Fs9xcyJg7s52rkpgu5pEX5FPQ0ebM/lCKmDb5KCxkoU=; b=Kr/ilcno0f4neb8ZE9+v4NloUuJpnKqOjzstcWUfLXOJlJQbGEVd1LZ6mKIbTSqEF51K7B 8ym2hptCWW20BFB7psPLjmNxLIS6YNhPP6k00KAkmTshBdTlWa7ZXuEeDystkWfreslCRc r+pf3GOrW7B9YDbX6Br9l3PUZvX98ac= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-1CGh2Qs_PGCFqBIbNkQ_3g-1; Fri, 16 Aug 2024 06:32:57 -0400 X-MC-Unique: 1CGh2Qs_PGCFqBIbNkQ_3g-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E27D1955D44; Fri, 16 Aug 2024 10:32:56 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.216]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 320363001FE5; Fri, 16 Aug 2024 10:32:52 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton Subject: [PATCH v1] mm/rmap: use folio->_mapcount for small folios Date: Fri, 16 Aug 2024 12:32:46 +0200 Message-ID: <20240816103246.719209-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Stat-Signature: 5kko1ju6sy311tdd7n4cgkzrjwdfnn15 X-Rspam-User: X-Rspamd-Queue-Id: B460C180026 X-Rspamd-Server: rspam02 X-HE-Tag: 1723804379-589059 X-HE-Meta: U2FsdGVkX1/QcvXoZat5CT4V0/d4OMPhy5Ijvim92vJW7AS9ZFvpcG66IgKJqQ5U64aPaKGEsgrsS/JvgrItZLtKu3wA6xVqrHrsLoz0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iiMGnb5+b2gGuch6pChWC5n06wJEwPMWYWj6bt/KYpVTugEDdgQycOnDxNas2URp2D8IYGcEIx/wRzhowqeur5GgHiBFHIWC+W8s1kZcqkLva6FM6hCfG8/I9TnyLT6r+z4uOm84vPLscCALxgq5ESuBbu/7wpE34s9S8GrG7CK99t2qWiZYHQ6XpNYKZWe1EayH7F/EPI6CAbhS35BkcSV/KYoZg/jt9sX5g== 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: We have some cases left whereby we operate on small folios and still refer to page->_mapcount. Let's just use folio->_mapcount instead, which currently still overlays page->_mapcount, so no change. This change will make it easier to later spot any remaining users of page->_mapcount that target tail pages. Cc: Andrew Morton Signed-off-by: David Hildenbrand --- include/linux/rmap.h | 4 ++-- mm/rmap.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 07854d1f9ad65..d5e93e44322e5 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -331,7 +331,7 @@ static __always_inline void __folio_dup_file_rmap(struct folio *folio, switch (level) { case RMAP_LEVEL_PTE: if (!folio_test_large(folio)) { - atomic_inc(&page->_mapcount); + atomic_inc(&folio->_mapcount); break; } @@ -425,7 +425,7 @@ static __always_inline int __folio_try_dup_anon_rmap(struct folio *folio, if (!folio_test_large(folio)) { if (PageAnonExclusive(page)) ClearPageAnonExclusive(page); - atomic_inc(&page->_mapcount); + atomic_inc(&folio->_mapcount); break; } diff --git a/mm/rmap.c b/mm/rmap.c index 4c330635aa4e7..c09c6c03fc9dc 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1165,7 +1165,7 @@ static __always_inline unsigned int __folio_add_rmap(struct folio *folio, switch (level) { case RMAP_LEVEL_PTE: if (!folio_test_large(folio)) { - nr = atomic_inc_and_test(&page->_mapcount); + nr = atomic_inc_and_test(&folio->_mapcount); break; } @@ -1535,7 +1535,7 @@ static __always_inline void __folio_remove_rmap(struct folio *folio, switch (level) { case RMAP_LEVEL_PTE: if (!folio_test_large(folio)) { - nr = atomic_add_negative(-1, &page->_mapcount); + nr = atomic_add_negative(-1, &folio->_mapcount); break; }