Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp644788rwi; Thu, 13 Oct 2022 03:19:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+X7Qk91Lq5H2/gTDggYcT6fhihc6ja/n8re0U/fMJ4ZuIRkmTJ6WMYorALGK77XuNrPZz X-Received: by 2002:a17:903:22c1:b0:184:983f:11b2 with SMTP id y1-20020a17090322c100b00184983f11b2mr7346425plg.40.1665656398177; Thu, 13 Oct 2022 03:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665656398; cv=none; d=google.com; s=arc-20160816; b=FuDydymw7BEUKlC/TvvSfZKfmT1FECGu/ueN0i4t2FqU+bpALCB24Iv4f/SSNWn3ns 6KiqJG+46H4kU+FH0Kn2+f1C5TX8t8LhX3AP3do1O71g8DdfjUsG5g5ewstummpOEA8j KCgBGEzErNgzYLYxwNcvGtZ5qyF0g/bMhVzF4z58v4aXgEF10c1NDM/RFHc42YxCxDoi prBwMDijRasq3gmTjvsb5NXyMwXZgevBSz3IxPOGpIDnhyoguWfOzOOOUD2TJ2iEhmZ8 1FIkibR0aPlWBVU+15HAL+88gzF88uGafIXVdUEeaTvkEHFpCSJ0/2eVAv0tQtHE0e7F 21Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=z78o+HpYoAcNgcRhH1mKkWfyfDptYAYJiQPW+GbhdF0=; b=Vd2+TqCJ+cAy7zQIDjTzuZXfPadWD6dcP8xGFVyAEKJXw87WwMVZ2Cxa6byvYR+Yh7 l4/3llgmiiWaw5OMUBeJahZbSjkU5AitIbD8oGQ/2w2XGwOBU3xpIp2Q7jggeeNNCoZx PuhkMwTtj8UNdXyFszvH9KV0RHkLhyH6E1fTkWQ6mBWf+O9uzlNGE9GSJ3gYSWzbHQiy MOiQ20DbXmygzdwy+Dc8HbnYw6elf4J4d6RmraCPmsS26oFbLnLAKtK5iDDjFfLSQnGb s86nxtKHsYYEpfd/FAuIF6sSaCoMnPyxVDMWFe53ROI9+/Jl9z+F83LsMCanv0TpFykR ERKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xwoIQnqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u18-20020a17090341d200b00176d22a068csi3692083ple.515.2022.10.13.03.19.46; Thu, 13 Oct 2022 03:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xwoIQnqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbiJMKKC (ORCPT + 99 others); Thu, 13 Oct 2022 06:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiJMKJ7 (ORCPT ); Thu, 13 Oct 2022 06:09:59 -0400 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2332167CB for ; Thu, 13 Oct 2022 03:09:55 -0700 (PDT) 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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