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 33A3A3254A9 for ; Tue, 9 Jun 2026 20:24:28 +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=1781036669; cv=none; b=t+K2Cqx8DvCbVnqimMpqsYyWLDMKmvER9Xm6OExT3TDU8NoUHebSZgISIvnSUouuC5LvwDwcCgYdpjERR7Xm2vABUXFLEKaiwg/mxEwS0DqGsOAQB+DM9c9knLaZKlnhPGjEgbTkXy6iJGkOYkxoknCF9W/bNydywdpmAH9WImM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781036669; c=relaxed/simple; bh=IhujjSgqeJpws/Riu9DYUzx33Ve6XDr9WLgE2Q20XtU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=usMYzCunwCV1/8hkoMgiMHN874e1xu93fyrtpLVI3p9i7tMFydlKD9zsoeMMO/pJC/n7zaECIyfsiUwsfYAGsrDv9rybNPOTTezyUi483fhIZf96JhgRhmPVF/0eG3KmDGGkYUz5xp3hXYpzGJrntVhtJVHW0eIRDTKHqILKAow= 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=RgO1q+TW; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=r0vPJiQF; 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="RgO1q+TW"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="r0vPJiQF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781036667; 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=nTUa2dI672FDZzKGV04n9VclX+EgypGNikp/bmy4IOc=; b=RgO1q+TWO8/tFnevqDoV0a0ucccHN42YiLl67jxFW0vgLsHQ/Kl3+HmciZZeHFCXI4NYky oPdoSFSqiVlVFkNpafkkF6kegF4dKiY62YyXTZYPMUnnotEyT7I2RODJcan1b+7df8ispa N55OA4nxhEeZmbKNAnVMAWT8f4G2nuw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-zt5fxTpWMGmxbP_UYKE0KA-1; Tue, 09 Jun 2026 16:24:25 -0400 X-MC-Unique: zt5fxTpWMGmxbP_UYKE0KA-1 X-Mimecast-MFC-AGG-ID: zt5fxTpWMGmxbP_UYKE0KA_1781036664 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490d3f03883so14523415e9.1 for ; Tue, 09 Jun 2026 13:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781036664; x=1781641464; 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=nTUa2dI672FDZzKGV04n9VclX+EgypGNikp/bmy4IOc=; b=r0vPJiQF6yhfR3rcJ9X5Fz19Kyn4OZ9ODrljOKUnSW12YRX+Z3A+mUH7Gnix3TT9HB BBSTQN/D7XP0Xtcmk/jV9qCQGYdKfND9PESHTz0lInAR5vADnGYAhGYcl5L+wmxOn2Ts sZTiL1yUerlHMV94Qh2FIGo8f7ELAwb28adhjYIvb9zU4drDkwjmdjWol26KFNw8x68F xkoUMlXdsO20N8Ir8FeYhqonQoUCFChV7Ll2orSPuLBu7B/4xC58KhP7YEs1s+CZBIrq W/a+1B8BhtnWcx8wM46B32twMQaTAdgRCu8HintXYjpDMoBTCeeuW2zcgm0HSqN62j2I 8Zjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781036664; x=1781641464; 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=nTUa2dI672FDZzKGV04n9VclX+EgypGNikp/bmy4IOc=; b=OQe4rb/BZrWqm3Zi0UosBOpTpeKS+JUpJmfrgCl3F+pHowr8WFf0RT7PASdJMIFMd4 QmJnMJSeXdEu16sli8+PZEULoOEsxnK1CSlCMp+gMp6mqGQby6vXsUE/VeOFz40rKWCJ aLY5UyhM5+IBif3qW5hb48cTHlDojnmKWV+3+lXEOGKrzx8+RWdzeaMe7EN3rYKAXqrZ kxJiu3KM/t+tZpB4UpuFtLvHVfiAhUn2GGw7OoA0s1r5ioJxeT0d5jZxlTNUqtExGY3o Q+YdtDSqtujdQtIhpeqJCujahZ3883Jh/yXvsjzl3dUr6AcFpiGrzDXsrRuEKHmfeItv n6iw== X-Gm-Message-State: AOJu0YyN3xmYlrf8RBLmQC/nFXuuxUCpTXcClRwvvYc0bsWUC/6JAtvO gJ3rstNwcfRrMWWMnoGQRU0+XOiGgNcysHL6lV0hD94KM7KE/vYrMZCGmbH4CgTjMRcxWnmyZtv zUabReVs9ilf18W+6cxMKFTET7LGzfoo1jmqwi1oAR/DfPLguVIu1d0kZqoya0TYByw== X-Gm-Gg: Acq92OERkbDpLa8B2CQfwVZhCygVRlTBs1cIQgo8SchdX88O/ekHtylR5+Z7ZBtIOqm 8i/Q3Su+s2KqBy9Y+/9U0CMm7z2OBvMskEtaoBwcg3q++pnUgbzIjKowyyBj6yjOdNoekQVr62y JmGorEhZQwyp/nVZL49qnv/o9Emy0Uv4DsSfYByOSdEYTjvRNRM8TNGUBtHzN1ytKgvRp88B4SQ qmGd7o+1mWKHQcRt1wN1uI0Nd306cxJyEj6U8TR4QC9/hvORzXpj5mMxp6CaRVrMPpfQsQf2qr3 wMAS4sSWfd7nM7Z8Nt5OzLor6AVHdP0Lb8QJghKxSt6ZqvKXik0s/BSslMkgLw/3JvSXaJDHeXL X9JwFW3PUjLLskqWtus7+h70J9cp0dJ3gVPYmpODF+6ueULeaP+Q6og== X-Received: by 2002:a05:600c:674f:b0:490:b4bc:4f3d with SMTP id 5b1f17b1804b1-490c25b06a1mr339837765e9.18.1781036664334; Tue, 09 Jun 2026 13:24:24 -0700 (PDT) X-Received: by 2002:a05:600c:674f:b0:490:b4bc:4f3d with SMTP id 5b1f17b1804b1-490c25b06a1mr339837295e9.18.1781036663783; Tue, 09 Jun 2026 13:24:23 -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 ffacd0b85a97d-4601f35133csm62850063f8f.25.2026.06.09.13.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 13:24:22 -0700 (PDT) Date: Tue, 9 Jun 2026 16:24:17 -0400 From: "Michael S. Tsirkin" To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Miaohe Lin , "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Muchun Song , Oscar Salvador , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Axel Rasmussen , Yuanchu Xie , Wei Xu , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , virtualization@lists.linux.dev, linux-mm@kvack.org, Andrea Arcangeli , Naoya Horiguchi Subject: Re: [PATCH splitout] mm: memory-failure: serialize TestSetPageHWPoison with zone->lock Message-ID: <20260609161227-mutt-send-email-mst@kernel.org> References: <20260609111020.e88f51a7b6ebc37360d66fdc@linux-foundation.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: <20260609111020.e88f51a7b6ebc37360d66fdc@linux-foundation.org> On Tue, Jun 09, 2026 at 11:10:20AM -0700, Andrew Morton wrote: > On Tue, 9 Jun 2026 06:12:49 -0400 "Michael S. Tsirkin" wrote: > > > TestSetPageHWPoison() is called without zone->lock, so its atomic > > update to page->flags can race with non-atomic flag operations > > that run under zone->lock in the buddy allocator. > > > > In particular, __free_pages_prepare() does: > > > > page->flags.f &= ~PAGE_FLAGS_CHECK_AT_PREP; > > > > This non-atomic read-modify-write, while correctly excluding > > __PG_HWPOISON from the mask, can still lose a concurrent > > TestSetPageHWPoison if the read happens before the poison bit > > is set and the write happens after. Will only get worse if/when > > we add more non-atomic flag operations. > > > > Fix by acquiring zone->lock around TestSetPageHWPoison and > > around ClearPageHWPoison in the retry path. This > > serializes with all buddy flag manipulation. The cost is > > negligible: one lock/unlock in an extremely rare path > > (hardware memory errors). > > > > Note: SetPageHWPoison and TestClearPageHWPoison calls elsewhere > > in this file operate on pages already removed from the buddy > > allocator or on non-buddy pages (DAX, hugetlb), so they do not > > need zone->lock protection. > > Sashiko is saying this doesn't do anything "Because > __free_pages_prepare() executes entirely locklessly". Did it goof? > > https://sashiko.dev/#/patchset/df06b66fe4ff8e925ee0714955abc2183a727b90.1780998980.git.mst@redhat.com > Oh. So it only helps with the prezero patches. Maybe other places where flags are touched locklessly. Not __free_pages_prepare. I was too focused on that. Scrap this please. I'll try to think of something. -- MST