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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3103AC433FE for ; Sat, 9 Apr 2022 02:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240549AbiDICHI (ORCPT ); Fri, 8 Apr 2022 22:07:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235359AbiDICHG (ORCPT ); Fri, 8 Apr 2022 22:07:06 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E3311140 for ; Fri, 8 Apr 2022 19:04:59 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KZz236mNczdZq6; Sat, 9 Apr 2022 10:04:11 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 9 Apr 2022 10:04:41 +0800 Subject: Re: [PATCH v8 2/3] mm/hwpoison: put page in already hwpoisoned case with MF_COUNT_INCREASED To: Naoya Horiguchi CC: Andrew Morton , Mike Kravetz , Yang Shi , Dan Carpenter , Naoya Horiguchi , , Linux-MM References: <20220408135323.1559401-1-naoya.horiguchi@linux.dev> <20220408135323.1559401-3-naoya.horiguchi@linux.dev> From: Miaohe Lin Message-ID: <84062e94-8356-a2b2-1074-e0143297223e@huawei.com> Date: Sat, 9 Apr 2022 10:04:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220408135323.1559401-3-naoya.horiguchi@linux.dev> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/4/8 21:53, Naoya Horiguchi wrote: > 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). IMHO, this issue will lead to memoryleak as page isn't freed even owner process is killed. So we might need a Fixes tag? Anyway, this patch looks good to me. Thanks! Reviewed-by: Miaohe Lin > > Suggested-by: Miaohe Lin > Signed-off-by: Naoya Horiguchi > --- > 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; > } > >