From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E3AC235E930 for ; Fri, 14 Aug 2026 03:18:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786677496; cv=none; b=FgWTryZT5omMD6wq45IuY7u5UEleQNWpRiZSfwtAsTyRCw3K8Wzys5pbEaLndCEt4rONSf4iUA350ibNfEz/e1v7Fs6pPhN7aBaFARfifszpC/Pe1qffSFEtLJKEIxcckh9CowfmxTFk19xOtlfBMKv+h6DjaOwOmnnVLtZLnWc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786677496; c=relaxed/simple; bh=mj1YrxYtF3aRY6ZuvJ5SMt/e0FlmV3L+p4OZoBnHYSw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AWD5xYsOlCdUD625UQLZ4ve5Xa+La488QZq2b3rrwcNWkx+MdHHWua5eYeLPJNAkllKZjng76C1+ZiBeqQIbp6gWOvpvQ5d6JMqSIKGKcRCvC0of9gEqmaWAy/mCJ0eLObBSQBaoMbvXxe00IAqJrQxGwwdHIzo2Y2YmAyYjb/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TJz9evUq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TJz9evUq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6C261F000E9; Fri, 14 Aug 2026 03:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786677494; bh=LsgWn8sG7KwPcJHSK2CgogemlhdZd4bBu7Jx3POkoZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TJz9evUqTStazAS2hs+GEFRo2dO95zacLioKESOh/64Gdo1mZOppeX26Vfv9cBonO UrB99vNLxkWx2+On3R8N/AL3lsEZq16lOoF+N/JJL4okKtYbmrQ0QsVpDh+wCWdWFt 1Q5CSmAwU1Ebq180oD0vSnTH5Q3hnQ5/jEYmZY89pF+PRiAfkXRw5B81IAo7XkT3HX S40aWVevme9sUAlMQ8D5KJtAOGRdFr7TONuUt/URwsnA8VnjjKMn3KNOU7Fc1PNghw GYt72oh7Kr+c1QikCWm8I6JsO8pRU11XHtRITb5MkIYPTGfJ79sYZwoglCJGL7rNnw MCM3mIEl6zLyA== From: SJ Park To: Breno Leitao Cc: SJ Park , Andrew Morton , Miaohe Lin , Naoya Horiguchi , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , david@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, kernel-team@meta.com Subject: Re: [PATCH v3] tools/mm: add hwpoison-panic tool Date: Thu, 13 Aug 2026 20:18:10 -0700 Message-ID: <20260814031810.88417-1-sj@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260813-memory_failure_rewrite_test-v3-1-f9fb6542cbff@debian.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Thu, 13 Aug 2026 04:45:15 -0700 Breno Leitao wrote: > Add a tool that enables the vm.panic_on_unrecoverable_memory_failure > sysctl, picks a kernel-owned PFN and writes its physical address to > hard_offline_page. Three page kinds are selectable with -k: rodata > (default), slab or pgtable. In all cases the host should panic. > > Example: > > # ./hwpoison-panic -k slab --yes-panic-my-kernel > injecting hwpoison at phys 0x100032000 (pfn 0x100032, kind=slab) > expecting kernel panic: 'Memory failure: : unrecoverable page' Too trivial nit, but I couldn't resist. Why print '' instead of the real pfn value, while we know it? > > In dmesg, you will see: > > Memory failure: 0x100032: unhandlable page. > Memory failure: 0x100032: recovery action for reserved kernel page: Ignored > Kernel panic - not syncing: Memory failure: 0x100032: unrecoverable page > > This lives in tools/mm rather than selftests/mm because every successful > run crashes the machine, which is not something to run from CI. > > The --yes-panic-my-kernel argument is required so an accidental > invocation does not take the box down. Looks useful to me, thank you! > > Signed-off-by: Breno Leitao Reviewed-by: SJ Park [...] > +static const char *inject_hwpoison(const struct page_kind *kind, > + uint64_t phys_addr, uint64_t pfn) > +{ > + char buf[32]; > + int fd, len; > + ssize_t ret; > + > + printf("injecting hwpoison at phys 0x%llx (pfn 0x%llx, kind=%s)\n", > + (unsigned long long)phys_addr, (unsigned long long)pfn, > + kind->name); > + printf("expecting kernel panic: 'Memory failure: : unrecoverable page'\n"); > + fflush(stdout); > + > + fd = open(INJECT_PATH, O_WRONLY); > + if (fd < 0) > + return "cannot open " INJECT_PATH; > + > + len = snprintf(buf, sizeof(buf), "0x%llx", (unsigned long long)phys_addr); Yet another trivial comment. I'm not a big fan of >80 columns lines, but I understand there are various tastes :) Thanks, SJ [...]