From mboxrd@z Thu Jan 1 00:00:00 1970 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8464FCD8CA8 for ; Tue, 9 Jun 2026 10:21:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D389D6B008A; Tue, 9 Jun 2026 06:21:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0E2C6B008C; Tue, 9 Jun 2026 06:21:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD5CD6B0092; Tue, 9 Jun 2026 06:21:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A7AAF6B008A for ; Tue, 9 Jun 2026 06:21:42 -0400 (EDT) Received: from smtpin01.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2F8694050C for ; Tue, 9 Jun 2026 10:21:42 +0000 (UTC) X-FDA: 84859982844.01.396F8EA Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) by imf30.hostedemail.com (Postfix) with ESMTP id 9408580004 for ; Tue, 9 Jun 2026 10:21:40 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=debian.org header.s=smtpauto.stravinsky header.b=VhOHgGRx; spf=pass (imf30.hostedemail.com: domain of leitao@debian.org designates 82.195.75.108 as permitted sender) smtp.mailfrom=leitao@debian.org; dmarc=pass (policy=none) header.from=debian.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1781000500; b=O9GZK1UEqBiwZn5MbFluQrXv1r8I2yzvPYMy+b48HudgY4hoLk0CLPMWVbJMt/MZQzHwVE 5BTVQoqLhBeuVQFbjc7rBbaYK6lGLGKhA5EwcdqsL/h+Q+twkICpneJ6bU1SG4ZuLsQoRm iC4fogE1Kq9olRQXz19iOTphvQXn9r0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=debian.org header.s=smtpauto.stravinsky header.b=VhOHgGRx; spf=pass (imf30.hostedemail.com: domain of leitao@debian.org designates 82.195.75.108 as permitted sender) smtp.mailfrom=leitao@debian.org; dmarc=pass (policy=none) header.from=debian.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1781000500; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bn99WnrCUkbfsqFDL/rbJh3F4JaVhuaOf+afGyjHySo=; b=cEFqXJ+2+s0P1eYd8rjNzwCD+CLUqLZiA/rqsfv6F1/DhwY2u8w7h+YHZBWYt+NXj/KNPY eKZz1jXDt+7PnPkQmCFX0c6Q6sw2b8Y/j8Tcf2Neb7FOiMhCnfQYwjjFWjlt63aUhuG/L7 RoM7oHzh7NoFx7bwpkwyP/bEUxgbNms= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bn99WnrCUkbfsqFDL/rbJh3F4JaVhuaOf+afGyjHySo=; b=VhOHgGRxICUsrfaJgFcDQvvyze d9kU96FibEcIKwwIChvLusQP1uyaxogC376OFW/AuBQ4/sC0tjMisozUvLOInxpkQWTJLqQDxZZJt 9DsEt2XtWd4Aguk3T5BvR8TsEhbi1Xln5HAwjm8PsQTTeiP/t4aBmQQCX4h5y3nVJpqslXa9MHvrz JnAK65jAXDj5l0AfPhc+AWdP7ElR7Eds261BEZMueM4J3CH460yFVbQNeSRuPsaDlPGN72UkyZuBG q8od3dNXMFHF/CM/cCdTCYcoDvC2X2ESqPKHy2+WIP6zSy9I6UZ80nZcxpw/yldz+Pku6i63nBnY1 roxpDzkQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wWtaD-008Kc4-2z; Tue, 09 Jun 2026 10:21:22 +0000 Date: Tue, 9 Jun 2026 03:21:15 -0700 From: Breno Leitao To: Lance Yang Cc: "David Hildenbrand (Arm)" , Miaohe Lin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kernel-team@meta.com, Andrew Morton , Lorenzo Stoakes , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Shuah Khan , Naoya Horiguchi , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Shuah Khan , "Liam R. Howlett" Subject: Re: [PATCH v8 2/6] mm/memory-failure: surface unhandlable kernel pages as -ENOTRECOVERABLE Message-ID: References: <33ef8821-c809-b7d1-ea77-6e8a07a6e784@huawei.com> <21732071-14a1-486a-951c-34de97b7c757@kernel.org> <4b27467e-935f-5587-2f48-5a794c30a592@huawei.com> <4953bcee-5a0f-2bc5-7295-63e5e7513e8b@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Debian-User: leitao X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 9408580004 X-Rspam-User: X-Stat-Signature: za9nxibarbqzcn8d3j5q1s6m5dx791bn X-HE-Tag: 1781000500-192771 X-HE-Meta: U2FsdGVkX180ScD7SH7BfSJiWXU1NTCj5rNEqG2+ixSGG4ZNb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meiIXJxLZ4cEiJmOCXRx3YKgNgjeZVHGW3DU/ysiMRflpqrbwmAQscIOid7zaw0fyng99hS2pNsn2Ba75HwlFuQHekCtyB/NNoo8a2MM6RK6R8IvY2KV2fdXtYWo6CWF87D7Yjj2yIndR9iD7e27kIu/cP85i0iveE6LrbpWD8uhm6B67W1rum1Qoxz7o7uKSPEw= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Jun 09, 2026 at 05:08:14PM +0800, Lance Yang wrote: > > > On 2026/6/9 15:09, David Hildenbrand (Arm) wrote: > > On 6/9/26 04:39, Miaohe Lin wrote: > > > On 2026/6/8 22:15, Breno Leitao wrote: > > > > On Fri, Jun 05, 2026 at 11:42:53AM +0200, David Hildenbrand (Arm) wrote: > > > > > > > > > > I mean, any such races can currently already happen one way or the other? > > > > > > > > > > Really, the only way to not get races is to tryget the (compound)page, > > > > > revalidate that the page is still part of the compound page. > > > > > > > > > > I'm not sure if that's really a good idea. > > > > > > > > > > But my memory is a bit vague in which scenarios we already hold a page reference > > > > > here to prevent any concurrent freeing? > > > > > > > > No, we don't hold one here in the case that matters. > > > > > > > > HWPoisonKernelOwned() runs at the very top of get_any_page(), before > > > > try_again: and before __get_hwpoison_page(). The first refcount taken in > > > > the whole path is the folio_try_get() inside __get_hwpoison_page(), which > > > > runs *after* the short-circuit. > > > > > > > > So get_any_page() itself never holds a reference at the check -- the only way > > > > one exists is if the caller passed MF_COUNT_INCREASED (count_increased == > > > > true). > > > > > > > > So on the MCE/GHES path -- the one this panic option exists for -- no > > > > reference is held when HWPoisonKernelOwned() does its compound_head() + > > > > PageSlab()/PageTable()/PageLargeKmalloc() checks. > > > > > > > > Given that, I'd rather keep it racy and take no refcount than add a > > > > tryget + revalidate purely for this check. As I've said earleir, an operator > > > > > > Would it be acceptable to add a simple recheck? Something like below: > > > > > > retry: > > > head = compound_head(page); > > > PageSlab()/PageTable()/PageLargeKmalloc() checks > > > if (head != compound_head(page)) > > > goto retry > > > > Sure. I guess it could still be racy in some weird scenarios where we > > free+allocate+free in-between. > > +1, sounds reasonable to me. Still racy, but acceptable here I guess :D Ack. I will post v9 shortly with this plus a couple of selftest fixes Sashiko flagged.