From patchwork Thu Jun 13 00:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13695694 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 896EDC27C6E for ; Thu, 13 Jun 2024 00:08:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A10F6B009A; Wed, 12 Jun 2024 20:08:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1517D6B009B; Wed, 12 Jun 2024 20:08:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F34446B009C; Wed, 12 Jun 2024 20:08:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D29916B009A for ; Wed, 12 Jun 2024 20:08:09 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4DCB7120E95 for ; Thu, 13 Jun 2024 00:08:09 +0000 (UTC) X-FDA: 82223927898.27.B2111E4 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf18.hostedemail.com (Postfix) with ESMTP id 7AE3A1C0028 for ; Thu, 13 Jun 2024 00:08:07 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DdddpP9Q; spf=pass (imf18.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718237287; 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:in-reply-to:references:references:dkim-signature; bh=bCCgBtm4kYdnlOxW6KC7ddfNlNkcCijSw9u/7Ny6adI=; b=F+BveROGBSOptEJXrQY1qfgN/rNpYV+ahRNMoC6qemMXrw09mJeIspkv83/x94bhZXsI/8 ZtJuZtcvarjuZIffmxrSSCYHDGXJqfJmxACackiyMAqLwhd68qgAmJE9Jqttshl1S0rzYm B2ZO9cFlMDduNtpbRX/poPhsNHNWpZY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DdddpP9Q; spf=pass (imf18.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718237287; a=rsa-sha256; cv=none; b=o3GvL0KOKoiG4a2ptacfqgBjJpXb0Ux1sm1d8ojEqRPRoUXj6h7DzP8eFl97JZD/DBQSkk iMc5yXOlMVX1+UJ/de2Vr0jkTF1VLMq1ilfwivTg6uvOR5bLIo/hwnmBp+sQfMzU70P3l0 aVSh5ipsGCXpgS/YUbJF5Jso1fkLlAA= Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1f44b594deeso4360215ad.2 for ; Wed, 12 Jun 2024 17:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718237286; x=1718842086; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bCCgBtm4kYdnlOxW6KC7ddfNlNkcCijSw9u/7Ny6adI=; b=DdddpP9Q//Gk3iHzLI0/U2TngoiOoR+ogYU3fMSxPF1fahWDgDMbB+3tmQ+oDecFfI bKyI1LPsfWepMGZfNdCypZAzaklg3syGm8BKxhiLLOD/M9q+AcRL+kj4BAd1Z8kJ4pyb kNjyzoouN46sR1YxuyWh7jAE69Qvas6xg1V97RudkkNmo/goSi4gk7ehz3/YQtK0uFXg 6AbulxVNwV51lbA5UGEzw7ctSqaOMfW27s4PznBy3k3tTw6N/igmVPlch1DOhRPAfmwa brNlsn2jmiC61G4yFYWipVgeg5Oo/9/gurA195aIiWI34PftcFMhaDbSaOX1GQPXM1V2 iuOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718237286; x=1718842086; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bCCgBtm4kYdnlOxW6KC7ddfNlNkcCijSw9u/7Ny6adI=; b=bcX4Nz61ZXiLFoSRfDZp4pleGr3+Yk6PEucgNmK0xQRzhqGPJXmVKal0/CjLPgOeC1 +odWsE9nSycR/WQiJP6KDbbyOWemjQBk0IG5o96PcR5UpnKuEhWwsYxTQu58MyL81Kpi ORtCF04TB6auIGA3Yk9sqpX4taD0nSBDuZ1wCENTe9vZBjui1AUONKdw6r4+rmzVM5jy xuojzxXmTN+MFztWlIb0M4xUiSJP6lKGo2ljslM0tO2Wfy2u1yZwXo7OR7LeZJcFji7k 2XdZgPopK8szww27AMC2O+IYQX+6F77ScVVNA4HR5xfSmqJWUice1GCV6uKv7HBI3U1H 13kQ== X-Forwarded-Encrypted: i=1; AJvYcCXttbTTTZoU3ygQh5XtlvBR3zN7w9gobXgXXpWbX1AnvV3t2cCUcnj3NBjGgTIud96l+Makq839Ykf1VJyhI8562Pk= X-Gm-Message-State: AOJu0Yzx7SGoa6NcyDYkLXWVcAAXPRwp9T/cU9ADG8eeeZW5zG/fQcl9 YUXo+15p0R/XfN3tVyFbwY/PcUrMLE0tUqzQ1OBx8ObEb2dSrklV X-Google-Smtp-Source: AGHT+IF3arrhaKJraeaVPGonKcs+bjSohtVRGhBzdoUWTP+KTk/DXUJQQ7qlrLIgRjj+zyClZOrwPA== X-Received: by 2002:a17:903:188:b0:1f7:1c84:13cc with SMTP id d9443c01a7336-1f83b713848mr38288865ad.42.1718237286072; Wed, 12 Jun 2024 17:08:06 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855f1af16sm525515ad.246.2024.06.12.17.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 17:08:05 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: david@redhat.com, akpm@linux-foundation.org, linux-mm@kvack.org Cc: chrisl@kernel.org, linux-kernel@vger.kernel.org, mhocko@suse.com, ryan.roberts@arm.com, baolin.wang@linux.alibaba.com, yosryahmed@google.com, shy828301@gmail.com, surenb@google.com, v-songbaohua@oppo.com, willy@infradead.org, ying.huang@intel.com, yuzhao@google.com Subject: [PATCH RFC 3/3] mm: remove folio_test_anon(folio)==false path in __folio_add_anon_rmap() Date: Thu, 13 Jun 2024 12:07:21 +1200 Message-Id: <20240613000721.23093-4-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240613000721.23093-1-21cnbao@gmail.com> References: <20240613000721.23093-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: bc95oww67unjqi7zxueyjfbp7qc1ojzy X-Rspam-User: X-Rspamd-Queue-Id: 7AE3A1C0028 X-Rspamd-Server: rspam02 X-HE-Tag: 1718237287-388138 X-HE-Meta: U2FsdGVkX19Oh74bPgfPnBUH6ZAy2qC+WmLq0DRVIvmxsKfoZHRYgyVoHEIEqZ3KfrRR9dnTBPxgI35aWo8OFEsf6UFgj8AeISy46FLv5ZaQDOTbZDr9YZita9XJkzxsxF7RZx0zUxXtludk7tLLC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9LZ2ydAJ97xrxCbPy4j8C0CKZ8qx2f+v0qI6xyZmvzrc+atHY/31exkXjBuwtjOUb5SknfCdO4FZPdsnxbbPcVgxOYdLR+jE8MlV1qkABvQ5sz1MCvdLgvSJKrUGUMV104/GmnmMk7OmDnfb59pgkeVhBxmVe7+KBqCaY9SLlkmpqd+c0MyJWunc7uaNR69PIdImvOhYrWmUi/fkfym7IXT1Z9xFl7oApWI81SeRhgc5g9icQkIunqSdPqLziirTlk1sAWTSBstZNeZA9ECwng== 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: From: Barry Song The folio_test_anon(folio)==false case within do_swap_page() has been relocated to folio_add_new_anon_rmap(). Additionally, two other callers consistently pass anonymous folios. stack 1: remove_migration_pmd -> folio_add_anon_rmap_pmd -> __folio_add_anon_rmap stack 2: __split_huge_pmd_locked -> folio_add_anon_rmap_ptes -> __folio_add_anon_rmap __folio_add_anon_rmap() only needs to handle the cases folio_test_anon(folio)==true now. Suggested-by: David Hildenbrand Signed-off-by: Barry Song --- mm/rmap.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index e612d999811a..e84c706c8241 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1299,21 +1299,10 @@ static __always_inline void __folio_add_anon_rmap(struct folio *folio, nr = __folio_add_rmap(folio, page, nr_pages, level, &nr_pmdmapped); - if (unlikely(!folio_test_anon(folio))) { - VM_WARN_ON_FOLIO(!folio_test_locked(folio), folio); - /* - * For a PTE-mapped large folio, we only know that the single - * PTE is exclusive. Further, __folio_set_anon() might not get - * folio->index right when not given the address of the head - * page. - */ - VM_WARN_ON_FOLIO(folio_test_large(folio) && - level != RMAP_LEVEL_PMD, folio); - __folio_set_anon(folio, vma, address, - !!(flags & RMAP_EXCLUSIVE)); - } else if (likely(!folio_test_ksm(folio))) { + VM_WARN_ON_FOLIO(!folio_test_anon(folio), folio); + + if (likely(!folio_test_ksm(folio))) __page_check_anon_rmap(folio, page, vma, address); - } __folio_mod_stat(folio, nr, nr_pmdmapped);