From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C5861C84A6 for ; Fri, 19 Dec 2025 00:21:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766103698; cv=none; b=SI5rZel4zaNjkF41HH8s/Efr9/g1556y30jsJvUGzIJ4WaWGZ3oPQEdqvXTtACEA8m2UgpjGDuwSRt5puswDufZq3Hkw6NLwJok5PndB32/4jVvBnQFVcXfCy+HVAfaxdl79qPfNFoFSK+6ujddNJtilKetdgjJeo8PYkQOHiZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766103698; c=relaxed/simple; bh=h7zv4G4cMt/3UcQVNei4a39O0o3NN/T+35CkYa8Rq7g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S1A8gW45mlrPnuRc1uortebgE3CRQRSzIgNF6RApatT15fLeSIe828SuQ/jYODhQleqhle6t6fkmU2CNMS2p9u5b49nAiJS+mgPYsKZF/4t4L67SwxTwVU7oYuPC+gmgO8tf77ViXVk4tit9RNsWj7YWXMVbaAO7Kc42EMOwSvo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jhI+/iMT; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jhI+/iMT" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-b79f8f7ea43so275599766b.2 for ; Thu, 18 Dec 2025 16:21:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766103695; x=1766708495; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=MqnJvZuDAhLr9ahmo6wXTWz98EHIguuClxuFq2i5FBk=; b=jhI+/iMTrPMR/Ay1N1esV6h4ueKGpEhQu59wdkLt79Au9quVIHUspG54wsNW6B9vs5 XDPQw9txqvPVwyDwRWyb80pknlJguUcMg8UMy+xgODFKefxkrKfHncCFiUctALIVgqet wJUiAhgq20Usvsk2Xl6jme8O+fmkcdMY51WWqTXmdIcEC4Uxu6u9fBUt+KKllvZMVD24 8GGuFGxBhZudpC9FdSXGgsZF0jM3oJ0VBE1K1prf1FQB43K1gx93rjo7JhoSML4+y7mL buY0Q3jtfshrNQsWKHTJQDD7ruWZOo9Oc8sWnIVerILx+yFwYeifrUDt8PU04IuAPtep CnKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766103695; x=1766708495; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MqnJvZuDAhLr9ahmo6wXTWz98EHIguuClxuFq2i5FBk=; b=J/6Fg6eGd2LbHeyxxiS+1wJpPtP++Is1VB2OWhdNNh+3/LbLodpLM9Zw33Ph+/s9iK kF40iVKy1UHNLsQiMoxbvd0eHX+sH5LMxMzkj743tcTlwsGYtuQRL4/kRWcQMqWCGz4C 5XSfWk6V6BSOVraswZzZoCY8EqVEYKRZKW6vTkBK1UCx9Nov1nU3kej3yvpl9iCiakOJ WZK7Xton1CjqB07WMM7cAqzMBmXuFhBa9qKPNXrDmVEUyJthu85cQqFpsswFj6aB1biX tFuhzB4lTuATjx8V65r/yEt4bZjvudMlcJ660rijPc36dZSrkXAuZknQwK1wm1igQsN0 YKxw== X-Forwarded-Encrypted: i=1; AJvYcCWDCMY+vqLV+qYnjSghnxGrehtkaP9/KwX1yL37t0ZI92lg9RIinePEKOubumv34hnyUHLRJYJ5c84h39w=@vger.kernel.org X-Gm-Message-State: AOJu0YxeWQk4Vk1EC1UAL9p95EQtMukXMlHpwAIdx1ZRxp2ecpPm18b8 8aGkIkhQGUONQ0eKxNNP6tx1wR6MUKn6nKs5Fq8V+BJbBCdlY2elwwEb4y1Pgy21 X-Gm-Gg: AY/fxX5iJuA1Gwxl9HfsJYNtPrZNd3JjTAkePzyVynGS0JpAGJFMWEgGo+xddbn+fYI vF95CrhrMYk7qlOEaMX4l/k8/3GqDuVqqPahw68RA7G8loox3TVzttVGFVqy4WWH29bu4MZpm2a S7z6e7ZEs9xMxi/mnM3uQ2jGlwZMsBO4EoOYHIoB4lPk8O75KL4asvzjoaN7fbqWn8up8lhq/2Q kWy2ge+XHZaxX8sxoRK5QjbmALbKn7ZTMdD3NV0oJNRNFnS6cGeN/Qw7DlS5m6dAMAOWbZLvyU/ tKlAikPHtilVErRAz7J0f6rW4gk1t2ZW5eyH1YGmFP2Yrh78rXv95S98t0tXgzlTgdqcVd+1SPd paQgcRh5kCN0puR0n3VbFc8ZLpxtVKYzGLkCzw+qb6V0ePYynrg3/yrfe/W4k04GGCZINbh/U2J I0iZ8ha+y6eQ== X-Google-Smtp-Source: AGHT+IHjCVy/tl38KId+ziTUgW5tLSsVdBoDRJeXfm+nWcc1y8jFZ9nAzDbBgJ6b95d9xHaO3lmZMQ== X-Received: by 2002:a17:907:9408:b0:b73:6998:7bce with SMTP id a640c23a62f3a-b8037152a19mr111138766b.33.1766103695157; Thu, 18 Dec 2025 16:21:35 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8037f51a74sm74641966b.63.2025.12.18.16.21.34 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Dec 2025 16:21:34 -0800 (PST) Date: Fri, 19 Dec 2025 00:21:34 +0000 From: Wei Yang To: "David Hildenbrand (Red Hat)" Cc: Zi Yan , Bijan Tabatabai , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, shivankg@amd.com, Baolin Wang , Hugh Dickins , Chris Li , Kairui Song Subject: Re: [PATCH] mm: Consider non-anon swap cache folios in folio_expected_ref_count() Message-ID: <20251219002134.uqgtnr43zz7vvvtd@master> Reply-To: Wei Yang References: <20251216200727.2360228-1-bijan311@gmail.com> <6b4cadb2-6246-48cc-9c76-64ba0a23198b@kernel.org> <0C218C18-916B-4BB0-8B37-AC82503E4AD9@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) On Wed, Dec 17, 2025 at 02:04:16AM +0100, David Hildenbrand (Red Hat) wrote: >> > > >> > > I am not very familiar with the memory hot-(un)plug or swapping code, so >> > > I am not 100% certain if this patch actually solves the root of the >> > > problem. I believe the issue is from shmem folios, in which case I believe >> > > this patch is correct. However, I couldn't think of an easy way to confirm >> > > that the affected folios were from shmem. I guess it could be possible that >> > > the root cause could be from some bug where some anonymous pages do not >> > > return true to folio_test_anon(). I don't think that's the case, but >> > > figured the MM maintainers would have a better idea of what's going on. >> >> I am not sure about if shmem in swapcache causes the issue, since >> the above setup does not involve shmem. +Baolin and Hugh for some insight. > >We might just push out another unrelated shmem page to swap as we create >memory pressure in the system I think. > One trivial question: currently we only put anon/shmem folio in swapcache, right? >> >> But David also mentioned that in __read_swap_cache_async() there is a chance >> that anon folio in swapcache can have anon flag not set yet. +Chris and Kairui >> for more analysis. > >Right, when we swapin an anon folio and did not map it into the page table >yet. Likely we can trigger something similar when we proactively read a shmem >page from swap into the swapcache. > >So it's unclear "where" a swapcache page belongs to until we move it to its >owner (anon / shmem), which is also why I cannot judge easily from > >[ 49.641309] migrating pfn b12f25 failed ret:7 >[ 49.641310] page: refcount:2 mapcount:0 mapping:0000000033bd8fe2 >index:0x7f404d925 pfn:0xb12f25 >[ 49.641311] aops:swap_aops >[ 49.641313] flags: 0x300000000030508(uptodate|active|owner_priv_1|reclaim|swapbacked|node=0|zone=3) >[ 49.641314] raw: 0300000000030508 ffffed312c4bc908 ffffed312c4bc9c8 >0000000000000000 >[ 49.641315] raw: 00000007f404d925 00000000000c823b 00000002ffffffff >0000000000000000 >[ 49.641315] page dumped because: migration failure > >What exactly that was. > >It was certainly an order-0 folio. > >[...] > >> >> I agree with David. Acked-by: Zi Yan > >Thanks for the fast review :) > >-- >Cheers > >David -- Wei Yang Help you, Help me