From patchwork Fri Apr 8 13:53:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12806795 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 ABF1AC433F5 for ; Fri, 8 Apr 2022 13:53:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 411B68D0002; Fri, 8 Apr 2022 09:53:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BF198D0001; Fri, 8 Apr 2022 09:53:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 260E58D0002; Fri, 8 Apr 2022 09:53:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 16C1B8D0001 for ; Fri, 8 Apr 2022 09:53:37 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BF555183B04A0 for ; Fri, 8 Apr 2022 13:53:36 +0000 (UTC) X-FDA: 79333854432.24.9BC944C Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf07.hostedemail.com (Postfix) with ESMTP id 3EB5340008 for ; Fri, 8 Apr 2022 13:53:36 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1649426015; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k5tFbU7BShyxeb1PXfEKBF6QTN+g39+2tO6/MCWhE0c=; b=uldKYj8wYfWzhPi+3mWtIYdcWHYJvIuyo9pyhadY1DxD+CHAWwh99kvT69HCH0FtdHMz4p DmGE/mw8ipjSFz4ig7FL0jCVxU0w9aUAfSVFqjg1kUJ3dZV0pjtDEzH7uRPcdOrpsn1Oi+ 32fBpogOy6U2CABsEBk5k8QuMihJDcM= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Mike Kravetz , Miaohe Lin , Yang Shi , Dan Carpenter , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v8 2/3] mm/hwpoison: put page in already hwpoisoned case with MF_COUNT_INCREASED Date: Fri, 8 Apr 2022 22:53:22 +0900 Message-Id: <20220408135323.1559401-3-naoya.horiguchi@linux.dev> In-Reply-To: <20220408135323.1559401-1-naoya.horiguchi@linux.dev> References: <20220408135323.1559401-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Stat-Signature: q9tdh7yzainqfjgbzaqt15xymxzom1c3 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=uldKYj8w; spf=pass (imf07.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3EB5340008 X-HE-Tag: 1649426016-17153 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: From: Naoya Horiguchi In already hwpoisoned case, memory_failure() is supposed to return with releasing the page refcount taken for error handling. But currently the refcount is not released when called with MF_COUNT_INCREASED, which makes page refcount inconsistent. This should be rare and non-critical, but it might be inconvenient in testing (unpoison doesn't work). Suggested-by: Miaohe Lin Signed-off-by: Naoya Horiguchi Reviewed-by: Miaohe Lin Reviewed-by: Mike Kravetz --- mm/memory-failure.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 2020944398c9..b2e32cdc3823 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1811,6 +1811,8 @@ int memory_failure(unsigned long pfn, int flags) res = -EHWPOISON; if (flags & MF_ACTION_REQUIRED) res = kill_accessing_process(current, pfn, flags); + if (flags & MF_COUNT_INCREASED) + put_page(p); goto unlock_mutex; }