Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp946949pxb; Wed, 6 Oct 2021 19:48:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcZi0HEklRfKDOZkl8Lv/jOYc96EAqGidKQ/9zaz6GsYBoH3gSf0R0eZZB+QGO5X6XoX7V X-Received: by 2002:a17:90b:17ce:: with SMTP id me14mr1929053pjb.112.1633574939131; Wed, 06 Oct 2021 19:48:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633574939; cv=none; d=google.com; s=arc-20160816; b=aPRE70MFs+qBuPBxTEKOvWT02pwLEAWrePYvqLGOks2KeHeyf2HKIELDSi3deGFz6v 23mGX1Zl1hZuQCBz5IrhWNENlxbGquyuyWmtM2A3kjWsf+eGoe8KMy58xrgh1UkTcwS6 pUh8uF2P9wpmhLKUjluRtyiANdI4/BlRsX7mG/03NeqChUd/U7T0nRXWs9FgLOKTOYZo 40dBF5HEDK8V7lG6xnv4Ud0GjH35pUrjXkzoH9wxXSyiNVvG/R0wYQcX1PHVy4OBAOQO FAtUkBxIftsd2XRCDR6udVYLHVqlQaZMQ9Oi59Q526pWpMwSjSucTddOs54006x8yEg3 PVvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=VyqxLGwIUlQqC1Zl70rnuaga2NhkHcEvoeQooiZvHpc=; b=lpcFztnEV1lnm14cWAjWu5jomes7Yk7lMdujrx+lWee6nBPPwa3pE+TVzNkvd/WGk0 sE8hPd5M4wOEb7pLWWPphN3a5qgRrrgI+a8Cn/QEubz5cqdceOiXDx7Mw/YRX8GVmAcD WY4mG99rL5c9QGzSwfJn7lT3N0k+5JoVf0ky5gSmI6IxcVhbwy+CZa8nVTtku/JNrl7V RUnCyHlfxOIT3WNvTNW3oxwEs53d30B26lvwTouqTFwwZE53NF9KOe5g39bDaAHghVbd zs+JjnFZicWk5KmqKeRHaIOkhH16rHauBsWh5pSVV8cCOseux0zpR4db+QqXvYeu1oWu DsCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="KpYpF99/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id em22si4221030pjb.188.2021.10.06.19.48.47; Wed, 06 Oct 2021 19:48:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="KpYpF99/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237798AbhJGCt2 (ORCPT + 99 others); Wed, 6 Oct 2021 22:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232262AbhJGCt1 (ORCPT ); Wed, 6 Oct 2021 22:49:27 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C34D5C061746; Wed, 6 Oct 2021 19:47:33 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id x7so16540751edd.6; Wed, 06 Oct 2021 19:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VyqxLGwIUlQqC1Zl70rnuaga2NhkHcEvoeQooiZvHpc=; b=KpYpF99/J1U8AB4Yg+f9FLyspi817QPhOlycUj58ufDQZjblYuPUQE03e57iuzjqLu 8oaXnl5GS4Fbr3eRlxseg91/g6YAgVck0VmK+0lUjc0ikXDnuB97yUYcv8KeQABV5wEo ZGYywMcMgm2paHxMYLqXK3/DIa2OoctbhkxgzarElrIoLgLczf+U1522/KHZCJStU0pD t6HugBhmK4OFi0WmAi8my9HfvvhgoDfqOSQdrAE34a8eIHGzCBlozTcqMUEc/6mOPoXy tr4dYRaVAcSCo4sDGCROFa6mNHYCxhTfMH/Y2mK/xemucQ6lnkcN6N181hChnYyYvVTB fkXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VyqxLGwIUlQqC1Zl70rnuaga2NhkHcEvoeQooiZvHpc=; b=GmWeTr4FOz0y/FJUeDpkEN/DLXNkiYx19kCnxYzel/V+Yg/BQd5HQA3RchkYQ3rfh/ 1Uo5y9qa9/5YHDea3+VLjIao3Z6rJ5TiWhR7x90BmER6X4cJn+nAM5GKgZhNfHgTQkhV dIsY+rhzdo2BxsQsSdqIimBMVfkGjnjy/DwSdIIn8CRpZyoDHHGeq4Psmf4CG/KHVD+Z LVL/XjU9xso4tRnmLULCfFxEf3w+yKnJBxTu0T/4owwKunIk7nxJYlMhY9Karit5JEe8 tDiMQD6JuPCDfkDWsvuX52g5PVcSE0NYuC0gWTlVIa8I3FRjI2lVDK+VigXi3Tt5D4/9 kLzA== X-Gm-Message-State: AOAM533/zCpxZ7S3vuyzFH1Qg084qvH0/357anKeUgo/flbjVmggvgJ3 RrktsM9RhwGHOL8fVnv1f9l/C8v6s21j89t98Rop+bv7V+Y= X-Received: by 2002:a05:6402:1b11:: with SMTP id by17mr2549661edb.71.1633574852376; Wed, 06 Oct 2021 19:47:32 -0700 (PDT) MIME-Version: 1.0 References: <20210930215311.240774-1-shy828301@gmail.com> <20210930215311.240774-4-shy828301@gmail.com> In-Reply-To: From: Yang Shi Date: Wed, 6 Oct 2021 19:47:20 -0700 Message-ID: Subject: Re: [v3 PATCH 3/5] mm: hwpoison: refactor refcount check handling To: Peter Xu Cc: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oscar Salvador , Andrew Morton , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 6, 2021 at 3:02 PM Peter Xu wrote: > > 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). Thanks for the suggestion. Yes, it makes some sense to me. And the code comments in patch 4/5 does says (the suggested version by Naoya): /* * The shmem page is kept in page cache instead of truncating * so is expected to have an extra refcount after error-handling. */ Will rename it in the new version. > > > +{ > > + 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(). Yeah, it is intentional. Before this change all me_* handlers did check refcount even though it was not necessary, for example, me_kernel() 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 >