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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A691EC433EF for ; Mon, 14 Feb 2022 14:48:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C8626B0073; Mon, 14 Feb 2022 09:48:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 077916B0078; Mon, 14 Feb 2022 09:48:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA8476B007B; Mon, 14 Feb 2022 09:48:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D7DE36B0073 for ; Mon, 14 Feb 2022 09:48:33 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 86078181AC9CC for ; Mon, 14 Feb 2022 14:48:33 +0000 (UTC) X-FDA: 79141666506.26.B9B2BC4 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf23.hostedemail.com (Postfix) with ESMTP id C5320140004 for ; Mon, 14 Feb 2022 14:48:32 +0000 (UTC) Date: Mon, 14 Feb 2022 23:48:26 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1644850111; 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=rXhKcwEx+FM0PjLnfOPxubSvhcDYX2y3m+/ZLrbv5o0=; b=Bcw7vJE4e7zEujOM/++xPnH9knA5vx1sTK9jeLc2aYH1nyjEKmJ4Az4kK9cVKCmVNElbDR 8UqShcUTzol075oVj/oO7w5EaFvxYmrQyRySpvdvFKSf8C+UolhcwdUki4+uh1IKIEXAvL uPD9eIRfvQNFRgWFEKo7cXNXUoWRvBg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Miaohe Lin Cc: akpm@linux-foundation.org, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/8] mm/memory-failure.c: avoid walking page table when vma_address() return -EFAULT Message-ID: <20220214144826.GB2624914@u2004> References: <20220210141733.1908-1-linmiaohe@huawei.com> <20220210141733.1908-3-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220210141733.1908-3-linmiaohe@huawei.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C5320140004 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Bcw7vJE4; spf=pass (imf23.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Stat-Signature: eyrwd6n1cxosczcw1tyq9ut9jcpc8m93 X-HE-Tag: 1644850112-636933 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: On Thu, Feb 10, 2022 at 10:17:27PM +0800, Miaohe Lin wrote: > It's unnecessary to walk the page table when vma_address() return -EFAULT. > Return early if so to save some cpu cycles. > > Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi Does this patch fix the real problem rather than just saving cpu cycles? Without this patch, "address == -EFAULT" seems to make pgd_offset() return invalid pointer and result in some serious result like general protection fault. If that's the case, this patch might be worth sending to stable. Thanks, 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 b3ff7e99a421..f86819145ea8 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -315,6 +315,8 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page, > pmd_t *pmd; > pte_t *pte; > > + if (address == -EFAULT) > + return 0; > pgd = pgd_offset(vma->vm_mm, address); > if (!pgd_present(*pgd)) > return 0; > --- > 2.23.0 >