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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD0C8C433F5 for ; Wed, 6 Oct 2021 22:02:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6101260F70 for ; Wed, 6 Oct 2021 22:02:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6101260F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B5A38900002; Wed, 6 Oct 2021 18:02:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B0A356B0071; Wed, 6 Oct 2021 18:02:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D0AE900002; Wed, 6 Oct 2021 18:02:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id 8619D6B006C for ; Wed, 6 Oct 2021 18:02:02 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2835D1839A139 for ; Wed, 6 Oct 2021 22:02:02 +0000 (UTC) X-FDA: 78667386084.26.306CC67 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id A9AF42D81 for ; Wed, 6 Oct 2021 22:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633557721; 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=KwYOi5FBnZz/GGBHEzCJubt9MvgZTdgF9/2Py157wwg=; b=gTevRTiAb6CA/rjwNIw6TjVuxy1w4I7xdaWCNFMiJl9VkKxv7juND/TvMSSdSBhKFZx7GE IJ9t6WJi+6AiibS3wvbVJrwWiNdMWDCBeBhtDEH6D709mvvHgdRjmD/hJaUQM3/4ViN18F VTEo1Vm6AMe9dl6fBk4seuGJv9Sdy0U= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-EU8VrVAvN-WoffYuFol3Mg-1; Wed, 06 Oct 2021 18:02:00 -0400 X-MC-Unique: EU8VrVAvN-WoffYuFol3Mg-1 Received: by mail-qv1-f69.google.com with SMTP id ey7-20020a0562140b6700b00382cf3eb480so3765556qvb.22 for ; Wed, 06 Oct 2021 15:02:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KwYOi5FBnZz/GGBHEzCJubt9MvgZTdgF9/2Py157wwg=; b=JzJj2u6vyVkv40learOBzbRF/uzVEFDsh+P34V10S9Y0MbM1gzglQh6GnZ3K3HCkFg et6VnahPqB+f44cwZfFOWqhHXp85yEMVH4oinplVeHku+wB5Fvko5goKy3o+DdUP+Fkf ZXlGyrzxzQkhgI5CM45+HPuZXHpuEiJtzhJigabFtcB12nwAYikQrm2Ef+mKDnZ4ddJk HtA0ze0hSgLLvTtmqI5GUxsntPBZn60X93taot4LKGJZAqPOHr2NyjxYkyetCKMHV1oO bnl8ivs0ZNLsqAul/tXZX3r5+lNPA1SHz3ItxdWO5uoh8ukaqR73CHyPvy5pH64bL9br t9nQ== X-Gm-Message-State: AOAM5335EyeMSHGVSeuW20TONc53DEXh4SiWPSVi45VJ+zaZsy56QVHX J2Ycwjzrrq4gpxWA2GCMkKTyMZBtZDILmPY5Xeke6XRihhrdT2+iByj3AcX4WJcJIL6wvXD8EQs hRoNVmRFSQTw= X-Received: by 2002:ac8:72d3:: with SMTP id o19mr799990qtp.19.1633557719536; Wed, 06 Oct 2021 15:01:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUY14CsRfg/wBWv/+kqo9Sz/TvI8iid6C/lEFVyVZtsk5eS9VSjdeR6pwre/6nqu4PMIIBHA== X-Received: by 2002:ac8:72d3:: with SMTP id o19mr799947qtp.19.1633557719251; Wed, 06 Oct 2021 15:01:59 -0700 (PDT) Received: from t490s ([2607:fea8:56a2:9100::bed8]) by smtp.gmail.com with ESMTPSA id o23sm14084849qtl.74.2021.10.06.15.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 15:01:58 -0700 (PDT) Date: Wed, 6 Oct 2021 18:01:57 -0400 From: Peter Xu To: Yang Shi Cc: naoya.horiguchi@nec.com, hughd@google.com, kirill.shutemov@linux.intel.com, willy@infradead.org, osalvador@suse.de, akpm@linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [v3 PATCH 3/5] mm: hwpoison: refactor refcount check handling Message-ID: References: <20210930215311.240774-1-shy828301@gmail.com> <20210930215311.240774-4-shy828301@gmail.com> MIME-Version: 1.0 In-Reply-To: <20210930215311.240774-4-shy828301@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A9AF42D81 X-Stat-Signature: 7qh6cqxcmzcxpkf17urgknwfu65jtmqc Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gTevRTiA; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf22.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-HE-Tag: 1633557721-748261 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, Sep 30, 2021 at 02:53:09PM -0700, Yang Shi wrote: > +/* > + * Return true if page is still referenced by others, otherwise return > + * false. > + * > + * The dec is true when one extra refcount is expected. > + */ > +static bool has_extra_refcount(struct page_state *ps, struct page *p, > + bool dec) Nit: would it be nicer to keep using things like "extra_pins", so we pass in 1 for swapcache dirty case and 0 for the rest? Then it'll also match with most of the similar cases in e.g. huge_memory.c (please try grep "extra_pins" there). > +{ > + int count = page_count(p) - 1; > + > + if (dec) > + count -= 1; > + > + if (count > 0) { > + pr_err("Memory failure: %#lx: %s still referenced by %d users\n", > + page_to_pfn(p), action_page_types[ps->type], count); > + return true; > + } > + > + return false; > +} > + > /* > * Error hit kernel page. > * Do nothing, try to be lucky and not touch this instead. For a few cases we > * could be more sophisticated. > */ > -static int me_kernel(struct page *p, unsigned long pfn) > +static int me_kernel(struct page_state *ps, struct page *p) Not sure whether it's intended, but some of the action() hooks do not call the refcount check now while in the past they'll all do. Just to double check they're expected, like this one and me_unknown(). > { > unlock_page(p); > return MF_IGNORED; > @@ -820,9 +852,9 @@ static int me_kernel(struct page *p, unsigned long pfn) > /* > * Page in unknown state. Do nothing. > */ > -static int me_unknown(struct page *p, unsigned long pfn) > +static int me_unknown(struct page_state *ps, struct page *p) > { > - pr_err("Memory failure: %#lx: Unknown page state\n", pfn); > + pr_err("Memory failure: %#lx: Unknown page state\n", page_to_pfn(p)); > unlock_page(p); > return MF_FAILED; > } Thanks, -- Peter Xu