From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 576AF3B7753 for ; Wed, 1 Jul 2026 22:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782944297; cv=none; b=CsETST5+0ODFDnOmUwEsu7K5P9h8BLNtGxROg4hWHFDu78TPY4wks6yrF6P4gjEMaQctoN3OSqMFUdXMur+n0kXe3Np3k+71XCfFt2bI1XtxDd2K5cfrTsE+KxRzWq+Dj9oRdD9Cpg1ystXAhfFvENKjKbfgFqFSDyfrOtyoR8A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782944297; c=relaxed/simple; bh=YFODPyiBTJ3qFQRmKDjGlGykbaq+xRFKBxJyqfTImiw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iJDw+v3Eu+c/Brn+UnIwgCSO68gfe8edr2veSXhdhyKnWo3CGsUX25pTP58vzZPQEISClTcXQNkZZODl55aSRtQYOPvohnuK099Tgm+g0VWLLbK7xFWzwXVGX0tM9RzijubXs+NVieoHZWtGvzWBqbn6gTZsZDlHnIg3O4aTsYo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HCqHEwal; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=gHC1fahn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HCqHEwal"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="gHC1fahn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782944294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Ki85T1yuIZ08q4/WMbISj88TpnfFulA/YFotMHfXQJE=; b=HCqHEwal8kJOYFSg3Ur2CUg4wRXUGu6uj3Bv+Z8Di76LT+nEHklzFMD7rXPz4la+B8phcQ y3SqKijXHbmoMOVr/69nXNg8uO+Xx7n/lMNMLE9JRI7LlEWVCnL0eu+HSb1x/PBN89PPQZ rkxHwWVjbItfTDMwaZr1A+WPxQrTJNw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-578-vp-b40eZMkyB8c4d0wb0yA-1; Wed, 01 Jul 2026 18:18:13 -0400 X-MC-Unique: vp-b40eZMkyB8c4d0wb0yA-1 X-Mimecast-MFC-AGG-ID: vp-b40eZMkyB8c4d0wb0yA_1782944292 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-493bb6a4336so10819255e9.3 for ; Wed, 01 Jul 2026 15:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782944292; x=1783549092; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Ki85T1yuIZ08q4/WMbISj88TpnfFulA/YFotMHfXQJE=; b=gHC1fahnhgUElTGB5GsMciX2HatR08oZe4CE9jTMo+CgKH64T7vs95HNBvhicREkKH ca8zEaaiWEvuEd/tW+ukZco4elqLsYPNu3o/ucxjRsSuIrnQl1lLtPnXctSh6WHNVjKT WaE6koaK2ipHhahVIN0yS9QaHiWCIHfDj722WGoMKijTR9ihSuhLCm1U2uGV0IR5StdT VTOaBJKZ1x3NcBZfukapl/3JzDDbujSizFgWKG2xJE5pBr0BpyDLsI4+yDHbxklw4dq9 kkXC8duYSS4b52HVgd1Uthlsna20w+CJIs8acDjTutOB51sScji9/+KaYwqO9s6RdyPs hqTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782944292; x=1783549092; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ki85T1yuIZ08q4/WMbISj88TpnfFulA/YFotMHfXQJE=; b=pdavUfBwv2+z++qrHnsSdvUzFgNVDgjfPTIO4hEFnzHQUi374m23emDwKT15m1vsQv GCmzsBcMSWJOioOLZq0vD9ufYO+3DGI+RPkxzKw3adNYd2LhjrRhMzeWtsWUym7xHkwQ 3KpeLGnJ96XnmbuCoWo3urC21kgbS84uE9u7z011alrnezJYwaKL90FVFSM/t/8/2+IV W34adv686PLJSk1YbLRwaR7brtGP9n9UxXwiC1wDHzEqdW9m2s0IgNi/gVTiDY8ls9TT 0frE2RYCr7AIAT63Otwny29THCbRvMKcutuHGaBgtEjZ778SFX+XzJ2tM6m0Lq1bGnLR 08sA== X-Gm-Message-State: AOJu0Ywm7FFDhNVX9fGH2LZmmzUYRlKMHHnRZbihjNGPMepRslDafRuW 5TGfiMUQqMLrEUOrcOY734paywtRJhFyJOBvA0cZMCQastjkm5CRmYuBR/b++HW584kLWBWJGcS 4cdupxsvkY6fFXpRiOoU81JqY5GvSGML22MI8FbPv9+wNdKMwmuh6Kx4FtZwgJmx3KQ== X-Gm-Gg: AfdE7cmfm7z6BWE+gL7vZ116ZIpBOrV0N90NHqM8xdX+Z8je2Wn5FdXWvyuFZe4Q/Jd lheHNuTgIzlDuTX+NlsASPEX6zfuVDFV1/QiedrQZGo4h5KsyuRQZIyrV6tMg7SKbLdxTzCjyFR H/HGaPbYs3pqSyNSE+I/5fIhX+7ngwRPpfXb2KHxjBdTHRcITgg5rYb8sDp9zWntYMxR1YXRdE2 KVH853E+OtNF+tkaMxsVmFk56xRomRsUVGlgwhLdRhJseRH2OOwP1sk8FgCcIzPNA3Q/+biKuR8 b3jM9wOctaREf9akSiPt0piJpz6gljXT5q7Dnacds9UJcg3F1RSzMinBr6AgeA6Kp8G/B4EusvT 2obam8HxxyG8uB9DebgeOcv0pv+3uIWs2 X-Received: by 2002:a05:600c:37cf:b0:493:bc97:916b with SMTP id 5b1f17b1804b1-493c2b986cemr52220475e9.26.1782944291750; Wed, 01 Jul 2026 15:18:11 -0700 (PDT) X-Received: by 2002:a05:600c:37cf:b0:493:bc97:916b with SMTP id 5b1f17b1804b1-493c2b986cemr52219795e9.26.1782944291279; Wed, 01 Jul 2026 15:18:11 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493be4da247sm104154245e9.7.2026.07.01.15.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 15:18:10 -0700 (PDT) Date: Wed, 1 Jul 2026 18:18:06 -0400 From: "Michael S. Tsirkin" To: "David Hildenbrand (Arm)" Cc: linux-kernel@vger.kernel.org, Miaohe Lin , Naoya Horiguchi , Andrew Morton , Oscar Salvador , Andi Kleen , Hidehiro Kawai , Rik van Riel , Vlastimil Babka , Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Hao Li , Kiryl Shutsemau , Byungchul Park , linux-mm@kvack.org, linux-cxl@vger.kernel.org Subject: Re: [PATCH 0/2] mm: memory-failure: fix HWPoison flag race with non-atomic page flag ops Message-ID: <20260701180511-mutt-send-email-mst@kernel.org> References: <20260630174852-mutt-send-email-mst@kernel.org> <2f884bfa-3cd5-4fba-8aa4-c2e68890ab64@kernel.org> <20260701041112-mutt-send-email-mst@kernel.org> <20260701043024-mutt-send-email-mst@kernel.org> <20260701112946-mutt-send-email-mst@kernel.org> 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: On Wed, Jul 01, 2026 at 06:17:23PM +0200, David Hildenbrand (Arm) wrote: > On 7/1/26 17:54, Michael S. Tsirkin wrote: > > On Wed, Jul 01, 2026 at 10:36:31AM +0200, David Hildenbrand (Arm) wrote: > >> On 7/1/26 10:33, Michael S. Tsirkin wrote: > >>> > >>> what do you think ;) post it? > >> > >> As RFC please :) [and if it's AI generated, obviously properly reviewed and > >> reworked by you] > >> -- > >> Cheers, > >> > >> David > > > > Not "generated" surely. But assisted, yes. > > What I thought. > > > Still hacking on it, but the difficulty > > with memory-failure is that fundamentally, it's not 100% robust. > > It's all a bit slapped on top of everything, yes. > > What I was wondering is, assuming the call_task_rcu() and it takes forever, > there might be quite a while where a hwpoisoned page that lost its bit is not > marked as hwpoisoned. > > So you'd actually want the one doing the test_and_set_bit() caller to wait until > the bit is stable. not sure I get it. > But that should be rather hairy as well. :( > > > > > For example, we have a fifo fed by hardware and consumed by a workqueue: > > > > struct memory_failure_cpu *mf_cpu; > > unsigned long proc_flags; > > bool buffer_overflow; > > struct memory_failure_entry entry = { > > .pfn = pfn, > > .flags = flags, > > }; > > > > mf_cpu = &get_cpu_var(memory_failure_cpu); > > raw_spin_lock_irqsave(&mf_cpu->lock, proc_flags); > > buffer_overflow = !kfifo_put(&mf_cpu->fifo, entry); > > if (!buffer_overflow) > > schedule_work_on(smp_processor_id(), &mf_cpu->work); > > raw_spin_unlock_irqrestore(&mf_cpu->lock, proc_flags); > > put_cpu_var(memory_failure_cpu); > > if (buffer_overflow) > > pr_err("buffer overflow when queuing memory failure at %#lx\n", > > pfn); > > > > > > if there are lots of these and the scheduler is slow and it overflows, > > it's sayonara you have lost the flag, right? > > I guess so. I assume on relevant hw you wouldn't expect a storm. But who knows :) > > > > > > > Oh and by the way, I just noticed that when buddy merges pages it does > > not check the poison bit. So it looks like there's a simple way to lose > > the poison bit - have it merge with a non poisoned page. > > When we poison, we try to take the free page off the buddy. At least that's what > I remember. Yes but not immediately - we set hwpoison then we try to take it off. > So I think we would just then go ahead and split the free higher-order buddy > page to remove the single page. Later we split, yes. But I don't see where it sets HWPoison after split - it calls SetPageHWPoisonTakenOff but it seems to assume HWPoison is already set. Am I missing something? It's late here... > > -- > Cheers, > > David