Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1069844pxb; Thu, 23 Sep 2021 17:32:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZOAjW4jjpN9YBEbi0A1oMYGanPBm7LuDK6pqRR0QPQsNvg9jjD3kepkI52Z9LFvDprRZt X-Received: by 2002:a6b:3f54:: with SMTP id m81mr6369305ioa.184.1632443533345; Thu, 23 Sep 2021 17:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632443533; cv=none; d=google.com; s=arc-20160816; b=Mdr4b2NEUPwc68ja9UQbmYQoRWrUTKMTrmLgBgCihY/GNgvuMoXIVIiK5gAIqu3noz uGLUvCBfc4KSsJktPR5SliIJpKLQT41FSQc3wVYnPNqqnN+M1pnrYB61jpbCNICYuSJv 1UaDqKFr0zl8DvvW9ZG1uVGO0ShYFw8bLLlNo4eNnlIcgDhM0Dbj7Juf+ju3u3KHgpiL W1Jypmh1cddL2GPvRgWC8vIgI1gp49bQEFADckI72EXH6bq88YDpEfERRCyTMcZyPMFO jwqduRUJsXGzk1yIyz6ZXzeLwiDRXxuXi9ZyTiUvlGPLRYPk1WNvedB2c6qKsPimTti8 zc4g== 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=zjfLAfWSo5szBRHYcbTSavPrNdYVRR33+yO7EWtRlRM=; b=FDI1tEs/1jotIcDyDOghQ5PiRFumFgxVDutFHPzzW96jv7liB0CTCaZyAiRzK6gkDT qgLXIOMTueflv+pG5ALK0rZbOVMabRgM1h3cRWtC6x09k0+WylpRwJAUHZdmSUlkkN0Z 6Sgc3aZdywsOKNqCl/+1TWUe1EY9Doba6UBO79SCnKssRO/+CnOJRVQFX2pPCZcwblh9 IYFEJy/Ds1+FskcHRRYL3CZpD89ooWH8hv0ySGwm77YUNmiuQH/CMFAtO5BZ7v0ptbYO VBAbqW0vQVWZxBpP35FCa9gSnZHJ9sH8b+gs60nUUKppP3ArW4ckXkzc43uQSHykAve2 x0ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MFbSUTUX; 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=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t11si10007017ilu.179.2021.09.23.17.31.58; Thu, 23 Sep 2021 17:32:13 -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=@linux.dev header.s=key1 header.b=MFbSUTUX; 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=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234774AbhIXAco (ORCPT + 99 others); Thu, 23 Sep 2021 20:32:44 -0400 Received: from out2.migadu.com ([188.165.223.204]:32176 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbhIXAco (ORCPT ); Thu, 23 Sep 2021 20:32:44 -0400 Date: Fri, 24 Sep 2021 09:31:02 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1632443470; 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=zjfLAfWSo5szBRHYcbTSavPrNdYVRR33+yO7EWtRlRM=; b=MFbSUTUXaAniZtOK418Rkutp3rZOsdXuttey/8upAfNJ+HTu+GvLj2uXRO9GaGdBI5BxLP C5qyaUPxFM0NgqvT2SFkRcW4jUAkU1iYC5KyGA/Lb4AKyqdGRwFYJ4+mQdau4YOVOIRa75 8yXS+pJu1cNwmzW8Y50F2WhWIY9my8o= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Andrew Morton Cc: Qi Zheng , naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com Subject: Re: [PATCH] mm/memory_failure: Fix the missing pte_unmap() call Message-ID: <20210924003102.GA974757@u2004> References: <20210923122642.4999-1-zhengqi.arch@bytedance.com> <20210923161738.990b61933c96df78bc1bf96d@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210923161738.990b61933c96df78bc1bf96d@linux-foundation.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: naoya.horiguchi@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 23, 2021 at 04:17:38PM -0700, Andrew Morton wrote: > On Thu, 23 Sep 2021 20:26:42 +0800 Qi Zheng wrote: > > > The paired pte_unmap() call is missing before the > > dev_pagemap_mapping_shift() returns. So fix it. > > > > ... > > > > --- a/mm/memory-failure.c > > +++ b/mm/memory-failure.c > > @@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page, > > struct vm_area_struct *vma) > > { > > unsigned long address = vma_address(page, vma); > > + unsigned long ret = 0; > > pgd_t *pgd; > > p4d_t *p4d; > > pud_t *pud; > > @@ -330,10 +331,12 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page, > > return PMD_SHIFT; > > pte = pte_offset_map(pmd, address); > > if (!pte_present(*pte)) > > - return 0; > > + goto unmap; > > if (pte_devmap(*pte)) > > - return PAGE_SHIFT; > > - return 0; > > + ret = PAGE_SHIFT; > > +unmap: > > + pte_unmap(pte); > > + return ret; > > } > > > > This is neater? > > +++ a/mm/memory-failure.c > @@ -330,11 +330,8 @@ static unsigned long dev_pagemap_mapping > if (pmd_devmap(*pmd)) > return PMD_SHIFT; > pte = pte_offset_map(pmd, address); > - if (!pte_present(*pte)) > - goto unmap; > - if (pte_devmap(*pte)) > + if (pte_present(*pte) && pte_devmap(*pte)) > ret = PAGE_SHIFT; > -unmap: This neater one looks good to me. Acked-by: Naoya Horiguchi