Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1024972pxb; Thu, 23 Sep 2021 16:20:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTSzGRSsXcjQG+Hx6HpY8ff4BqeeJhZ4eIWkZEFnMwHl5C4MnCzunxpR1M5oen7M5XkBZq X-Received: by 2002:a17:906:dbd8:: with SMTP id yc24mr7887252ejb.221.1632439207168; Thu, 23 Sep 2021 16:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632439207; cv=none; d=google.com; s=arc-20160816; b=wmtWXdVGd3FrmaqEWpyhnlShmbCCO9vZ+FLHOQ7lf4dzC09DlfHJLaNm1dh4CnhqvP PIsHUHKKGehvWlDJ2rkEI5aJTb90u4yeDh2qEfseW/FcCAPszcjXucqelsm+s0mDWyct g3T+oniMLwKML9tR+BEA7hAFCzfnpbo7izOfo0x6QecZNtOSH4F20tn9rubwL/pKVB7V ZxNiJH5xZeG2mwFD7ZnoV7UR41NeHXE7oTheRmHsKzk6Jceq3s8l7TMxQwOkLGzavIRn 76qgsXcXlBGjOZ7aGw6ZD74y4Pxsk31GxSdPOA6UuOP7+zz5XQhSJDbrPDYmOCJBVyik 2MyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=4Ge9AvJs0v28opvnyV5wPrEHJ4gYfDrzmSgTcbWZxyc=; b=OhHoO5jO+KkDtY3msWi4fWEBxflRMHA+6eRlkt37aeyBlGfuKBWdO3vbG3d0B2dN3J U8nAxDLGSqSeZxqqyxu5HSw5KlxVOh07urVlGf/TflGKvtUTUF50EEQXn8DhQPHVpvf5 lbTc7wAfvPgqG4dqIH0imTiuIEiXsqqR4/1VW3ipCDAgitWP5vmG/quPxKBrL/c0i08U 8RaESYcjgvQsJjUV0VKJsA8qzqoEBNu3uBuh2mSTzoz41C0z0XB29zzDha1r8AA8+oxd K3HxwWFVheZM6FtO9XrvijGpseksXoWiwQ2pVLXz3aCuHDbzbIt1MKq/R991BsNw2moc k/cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=HreHvNj6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f17si7958559ejt.20.2021.09.23.16.19.43; Thu, 23 Sep 2021 16:20:07 -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-foundation.org header.s=korg header.b=HreHvNj6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243531AbhIWXTN (ORCPT + 99 others); Thu, 23 Sep 2021 19:19:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:48648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243572AbhIWXTM (ORCPT ); Thu, 23 Sep 2021 19:19:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A9A160E94; Thu, 23 Sep 2021 23:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1632439059; bh=aovSY1+j/p4VcwH3XgkVFJ6AKhHLQs9U16f85Ij55u4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HreHvNj6W8lCJitqQAcOFJ/XWQr05sDs5HuQ7X66Vdf3gsUyHKgag3fA4dbfRUa3P VzD1idLDZbHhW7AIY659g+7nJvtfq7baXXVHZ3F2rXF4VVoOwIm9kOkrCPRfqi+/zi vPKY14Gxk0h1tlB+Ejl//3om6d2xMbyc1vVDQHS8= Date: Thu, 23 Sep 2021 16:17:38 -0700 From: Andrew Morton To: Qi Zheng Cc: 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: <20210923161738.990b61933c96df78bc1bf96d@linux-foundation.org> In-Reply-To: <20210923122642.4999-1-zhengqi.arch@bytedance.com> References: <20210923122642.4999-1-zhengqi.arch@bytedance.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: pte_unmap(pte); return ret; } _