From patchwork Thu Jan 18 11:10:35 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: 13522713 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 DCA4BC4707B for ; Thu, 18 Jan 2024 11:12:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 771C36B008C; Thu, 18 Jan 2024 06:12:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 721086B0092; Thu, 18 Jan 2024 06:12:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59AA56B0093; Thu, 18 Jan 2024 06:12:31 -0500 (EST) 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 485986B008C for ; Thu, 18 Jan 2024 06:12:31 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 18477160AF2 for ; Thu, 18 Jan 2024 11:12:31 +0000 (UTC) X-FDA: 81692168502.02.4B0C112 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf16.hostedemail.com (Postfix) with ESMTP id 431B6180018 for ; Thu, 18 Jan 2024 11:12:29 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=m6QVRXFQ; spf=pass (imf16.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.180 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=1705576349; 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=lCBEGTZpNMmcOnq2Y92D+y0mof5icxn15UOhqT4EV4Y=; b=iedAE1s0yHcBhfzLABssg2D2lvseBBWTOoNRIV3715p0fihfqs98LkvqyAymRfZ1KcaMA0 mWBYBvNr3K0YL7lwRPL9/Y61HB8BdsRS+EayYKkrQ5ES2GMJUXXVS4yAZmtNvELKP4aTr3 hic1MEgcqzYjrzWrWxkbKT31YgSiNqw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=m6QVRXFQ; spf=pass (imf16.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.180 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=1705576349; a=rsa-sha256; cv=none; b=h3C3l8s1TSzlwRrCPl9QCyQt0zCwdVN3WViJzAduzigoTPGM7POQ+QrQFXZjOzyO1thBiJ s8YtrCLuuH7MVwH3ey1/2KSAnC8+fNRpZCBc/N3qngwuQfcTrtz3IEyuUi6nRFSMw1nNC/ AbibVJuRY/rUScqne2jAFd1em2TVUr0= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6dac8955af0so7015751b3a.0 for ; Thu, 18 Jan 2024 03:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705576348; x=1706181148; 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=lCBEGTZpNMmcOnq2Y92D+y0mof5icxn15UOhqT4EV4Y=; b=m6QVRXFQ4bTtZvyDvbR1VKDQaCtr0ZuFXb+Jdi8yGTPkWJlwxSaeafDxwWsNVxfXug XFtCAIiSCIf7e7Ro+6i88d4zTnX5Ci8WBeX2hx17Ax9NmXxysMNqiR9wLUySBK3Y6cac iVrS2Ja9DMO5E9+vztJSDdwWvrb6HdbOA+63HoTecFJ/6Cjdp/wn1gXsuDT3q8fS4GJU a4adc7JYrYAuM812UvCOyUD2n9REdyCbWZUxq6JurvYRnZ130jAX6uhQxzq0oNhf8wyU H1mEU3Thh+5vFmXhydb6Cve50HpB24J2M2cStf50sgYSV5PeJRsvEAVJ0OgdwwmUNvfB icSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705576348; x=1706181148; 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=lCBEGTZpNMmcOnq2Y92D+y0mof5icxn15UOhqT4EV4Y=; b=gb4/gNESvlgOqZg9YWDZ+F4kzWqdgLVmobP2yM2VuJXqweAzuDWtl9pMd5Xuhh0T+5 q9u3RBDMyzPoDg35GMdLshD2CLkJ6VIjV0LpEgmILGttWUPEYMXeGOce97dAWxNo9B3O kdm05q4bzqIxt9rsWYnYUuAMdpmI80BXdqRZ7qxYJQ+KqYtoJ57ptO4XK+I7o5Fddtw2 L9/594ytvyN/+EIGlRNbt6J24+1aFfd0O61/vk4JEVqkh5HvYGj/OlGonvNfiIYK0oTu WG9S6Imc7wWZi9SKgqXK2asM6EJHTuGR8IKLjxE3hPR2KLx7RexbdvxHWsdaPHUejexk JJ2w== X-Gm-Message-State: AOJu0YyPfeAlSTCvMcswqqlDVV8FKvFyzTug30L7oZWViWLDZArhyrm8 ops0NTRkXSy0RNieebPKX6OARtGtsljEWymO+JnpDmHGrph6l8zj X-Google-Smtp-Source: AGHT+IEJstXUsC4BpkRjY9scs4NUCR+YL22P3xRiQhsTqcfdW5F99LeuFxkMM1kuf1dvP6YKKu38lg== X-Received: by 2002:a05:6a00:170c:b0:6db:6ed8:4e9f with SMTP id h12-20020a056a00170c00b006db6ed84e9fmr684987pfc.56.1705576348144; Thu, 18 Jan 2024 03:12:28 -0800 (PST) Received: from barry-desktop.. (143.122.224.49.dyn.cust.vf.net.nz. [49.224.122.143]) by smtp.gmail.com with ESMTPSA id t19-20020a056a0021d300b006d9be753ac7sm3039107pfj.108.2024.01.18.03.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 03:12:27 -0800 (PST) From: Barry Song <21cnbao@gmail.com> To: ryan.roberts@arm.com, akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, mhocko@suse.com, shy828301@gmail.com, wangkefeng.wang@huawei.com, willy@infradead.org, xiang@kernel.org, ying.huang@intel.com, yuzhao@google.com, surenb@google.com, steven.price@arm.com, Barry Song , Chuanhua Han Subject: [PATCH RFC 5/6] mm: rmap: weaken the WARN_ON in __folio_add_anon_rmap() Date: Fri, 19 Jan 2024 00:10:35 +1300 Message-Id: <20240118111036.72641-6-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240118111036.72641-1-21cnbao@gmail.com> References: <20231025144546.577640-1-ryan.roberts@arm.com> <20240118111036.72641-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 431B6180018 X-Rspam-User: X-Stat-Signature: nsctgu94t6auxs7q36j6p4wghz16dcxp X-Rspamd-Server: rspam01 X-HE-Tag: 1705576349-427242 X-HE-Meta: U2FsdGVkX18Sj5kUu5PLqzyVje3/nycjOvDQui1SnLTcYI2ezqo15+yAeRP8Hyd1HeoS1bBEQPdv3mac9ZuvNxHUp3qxwu/6EHVvtxLJRg63iBgPLYY9H0ptWbO8b486umJW4Ffm3IKeuUQ5nKEs3OKw93LRin6TfJ5RncufhLIaVUM+jUDs8mtwkffr7MM4sSKR66BP8gjkyL1AANm8nk0c3x/9uhcSMtmTAs4mk+YNmRv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gnV78766VwBx6s0CHXoYhFEMyv3NaQJhf1c//NzKpdFt+yY0kn2pndK3E+Qrh1bK8bBwJV8Tf311df3ISij2L7vLK2HpDFg8fVIeVa1Xp4TpcZLM9qEV8Tgu5usgPEOAGlzMpQKFuM4rNanhDk+aBeZgz1FYSl2xbIvP0uai2h0awshmkxXdrEYd3xL3a3zppNAawnw== 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 In do_swap_page(), while supporting large folio swap-in, we are using the helper folio_add_anon_rmap_ptes. This is triggerring a WARN_ON in __folio_add_anon_rmap. We can make the warning quiet by two ways 1. in do_swap_page, we call folio_add_new_anon_rmap() if we are sure the large folio is new allocated one; we call folio_add_anon_rmap_ptes() if we find the large folio in swapcache. 2. we always call folio_add_anon_rmap_ptes() in do_swap_page but weaken the WARN_ON in __folio_add_anon_rmap() by letting the WARN_ON less sensitive. Option 2 seems to be better for do_swap_page() as it can use unified code for all cases. Signed-off-by: Barry Song Tested-by: Chuanhua Han --- mm/rmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index f5d43edad529..469fcfd32317 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1304,7 +1304,10 @@ static __always_inline void __folio_add_anon_rmap(struct folio *folio, * page. */ VM_WARN_ON_FOLIO(folio_test_large(folio) && - level != RMAP_LEVEL_PMD, folio); + level != RMAP_LEVEL_PMD && + (!IS_ALIGNED(address, nr_pages * PAGE_SIZE) || + (folio_test_swapcache(folio) && !IS_ALIGNED(folio->index, nr_pages)) || + page != &folio->page), folio); __folio_set_anon(folio, vma, address, !!(flags & RMAP_EXCLUSIVE)); } else if (likely(!folio_test_ksm(folio))) {