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]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6E14C433FE for ; Thu, 13 Oct 2022 10:09:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CF3E6B0071; Thu, 13 Oct 2022 06:09:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27E8C6B0073; Thu, 13 Oct 2022 06:09:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 146B96B0074; Thu, 13 Oct 2022 06:09:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 01D7E6B0071 for ; Thu, 13 Oct 2022 06:09:57 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B9FC640792 for ; Thu, 13 Oct 2022 10:09:57 +0000 (UTC) X-FDA: 80015505234.27.AA8CE6D Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf26.hostedemail.com (Postfix) with ESMTP id 7ADEE14002F for ; Thu, 13 Oct 2022 10:09:55 +0000 (UTC) Date: Thu, 13 Oct 2022 19:09:43 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1665655793; 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=z78o+HpYoAcNgcRhH1mKkWfyfDptYAYJiQPW+GbhdF0=; b=xwoIQnqclf6LpmSJkDvCWops4flotPrAtjRAXUqIXRAHWLXxItStjoTUbquc7DNyJNtvVZ uv7ovwtnf60mSqSgEdKNXGZY8Es0qAa1+hoPPR1L2+r6Z1GoAlEh6obYJTAOSpJyF5/Ugi zBWclQ9jxKFDKJ4RLyfpHrMfQXZ9Q2E= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Oscar Salvador Cc: linux-mm@kvack.org, Andrew Morton , Miaohe Lin , David Hildenbrand , Mike Kravetz , Yang Shi , Muchun Song , Jane Chu , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 4/4] mm/hwpoison: introduce per-memory_block hwpoison counter Message-ID: <20221013100943.GA1505152@u2004> References: <20221007010706.2916472-1-naoya.horiguchi@linux.dev> <20221007010706.2916472-5-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665655795; a=rsa-sha256; cv=none; b=cTwWuGnchYBrPRqyhizv6YvDu7ot21w4HJ+OLIcKwP2jCKcr3BAeATP+SgvInr6dlVSFlh rKjTju4OoTYPPs+3qDr4x2idf92j6EhXW9qUN1qWbQKuoSmrUAPepoM2x1rh3KcRwrVtlD EZxdhz6NdH/diVfUpLZJzFxsilFHScg= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=xwoIQnqc; spf=pass (imf26.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665655795; 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=z78o+HpYoAcNgcRhH1mKkWfyfDptYAYJiQPW+GbhdF0=; b=7V7O/W0sLqVMN+e9Z06pRuE4k0IbNcLmKl/Ri0TAYpqgsQwN98HblboXEvc/b2a3R+HH9V bo7G3yrSbjaQz4tWIGQSdU0JWg70JRse5Oj4Tqptd4INLBFTNI24p+f7xMGdYp9K6edUvR jYO90OuLgdAytk30xZZ2nUVHNRxSI2o= X-Rspam-User: X-Stat-Signature: p8bmhawmgmecfyh9urzwiyuxcj5yitwf X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7ADEE14002F Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=xwoIQnqc; spf=pass (imf26.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-HE-Tag: 1665655795-734954 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 13, 2022 at 10:33:45AM +0200, Oscar Salvador wrote: > On Fri, Oct 07, 2022 at 10:07:06AM +0900, Naoya Horiguchi wrote: > > From: Naoya Horiguchi > > > > Currently PageHWPoison flag does not behave well when experiencing memory > > hotremove/hotplug. Any data field in struct page is unreliable when the > > associated memory is offlined, and the current mechanism can't tell whether > > a memory block is onlined because a new memory devices is installed or > > because previous failed offline operations are undone. Especially if > > there's a hwpoisoned memory, it's unclear what the best option is. > > > > So introduce a new mechanism to make struct memory_block remember that > > a memory block has hwpoisoned memory inside it. And make any online event > > fail if the onlining memory block contains hwpoison. struct memory_block > > is freed and reallocated over ACPI-based hotremove/hotplug, but not over > > sysfs-based hotremove/hotplug. So the new counter can distinguish these > > cases. > > > > Signed-off-by: Naoya Horiguchi > > Reported-by: kernel test robot > > I glanzed over it and looks good overall. > Have a small question though: Thank you for looking. > > > @@ -864,6 +878,7 @@ void remove_memory_block_devices(unsigned long start, unsigned long size) > > mem = find_memory_block_by_id(block_id); > > if (WARN_ON_ONCE(!mem)) > > continue; > > + num_poisoned_pages_sub(-1UL, memblk_nr_poison(mem)); > > Why does num_poisoned_pages_sub() have to make this distinction (!-1 == -1) > for the hot-remove stage? The first argument is used to find memory_block including the given pfn. And in the above context remove_memory_block_devices() already has the pointer "mem", so recalcurating it looked to me not necessary. Moreover, this code is about to free the memory_block so updating the counter inside it can be avoided. This is just a tiny optimization, and there can be better option. Thanks, Naoya Horiguchi