Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2885034rwd; Mon, 22 May 2023 05:56:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5cY7vsMsA3i59RYQmjwWsUeRCQVLjcaL5QAYBQcm29biugBvOLV9GoSxvX7CTMptanGGLe X-Received: by 2002:a05:6a21:99a4:b0:10c:2cb7:29b1 with SMTP id ve36-20020a056a2199a400b0010c2cb729b1mr566178pzb.51.1684760216822; Mon, 22 May 2023 05:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684760216; cv=none; d=google.com; s=arc-20160816; b=lcyS8R0YkqsGgKHH3CPx9T6MbJeAYJizQRwS3lbLyXQ01lmAZSRyJt8xwYObwiEkBh e9vZ2fgf4t/KLcvitckefZ106hEjGtlQNDIhumPCvMdCUK8MgFjq5n2M+s7tzun4IbY4 cc+DooqjFK4/Z1dfdlao5J9NReDOhb/eto483v0G76CH35Ktnz0OaVrzvfClZOJ+T2f+ aGsXdRvFbQlOay2AyCGminNr1WdWIo7EnbPe0tig0obAWNFYqabPcOeOsKP0xHsHnzOO sysgOb06qm2H7W2h2hQi6SHrdww7lH+mArm44kDPuj5hEjUhc8S/q6Mkty0tTwDevTmb IJ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=r1IveFjFr/0G5nfPmQ1aYDtWSC7eo753hQs8Co832NI=; b=RNYdk0DtJL2cfYUqDxOqBmaNBeM51fOodrxmt5tve6j24Ck6dkX1TlkxxSLg7IGhYn nDtmIXZagNOkm3lBrv2pLozYIDwcQRGWgHv2lQnMCETTVDwhv7hxH8GsyP6gkX/fNJB8 GQM/Iu5k3/Uz57wqzm/tYqzKh0bi4VHVA/rv5ejPtuKUJKQdzeqSGIzQ9+pC6T7dcLmb TyPcxi78CXig7smmsov8OayHG+nCIF6kaAAybYNqieIBB8F1T7yMXB0sph0cauyai3da XK/GAGnGshJqLTyjYehL/nT+Dv/KxMZ10IPglX4NylQtZop3Sbcx5nOxdi8EOoIqVjkz pM5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jE9wkVE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z21-20020a63ac55000000b0051b578dfc51si4510606pgn.744.2023.05.22.05.56.44; Mon, 22 May 2023 05:56:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jE9wkVE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233972AbjEVM1q (ORCPT + 99 others); Mon, 22 May 2023 08:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233106AbjEVM0w (ORCPT ); Mon, 22 May 2023 08:26:52 -0400 Received: from out-19.mta1.migadu.com (out-19.mta1.migadu.com [IPv6:2001:41d0:203:375::13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E17E0 for ; Mon, 22 May 2023 05:25:03 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684758301; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r1IveFjFr/0G5nfPmQ1aYDtWSC7eo753hQs8Co832NI=; b=jE9wkVE1qhHuRF/ah9JoCOIcSKA1B5FaHdoFa8smx3qZO2ktUEzWV+AR/VczQifC9+sOee TiXSanP8l15OrBvvOE0EBtkNnPiIQtpkyn/FTyvbZf9T+d9sb+mV5vS1dEQ4wTiFdAyfoU ejXCpsZ0kjD0eVff0b56qxa/xQAqsJg= Date: Mon, 22 May 2023 20:24:45 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 17/31] mm/various: give up if pte_offset_map[_lock]() fails Content-Language: en-US To: Hugh Dickins , Andrew Morton Cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/22 13:10, Hugh Dickins wrote: > Following the examples of nearby code, various functions can just give > up if pte_offset_map() or pte_offset_map_lock() fails. And there's no > need for a preliminary pmd_trans_unstable() or other such check, since > such cases are now safely handled inside. > > Signed-off-by: Hugh Dickins > --- > mm/gup.c | 9 ++++++--- > mm/ksm.c | 7 ++++--- > mm/memcontrol.c | 8 ++++---- > mm/memory-failure.c | 8 +++++--- > mm/migrate.c | 3 +++ > mm/swap_state.c | 3 +++ > 6 files changed, 25 insertions(+), 13 deletions(-) > [...] > diff --git a/mm/migrate.c b/mm/migrate.c > index 3ecb7a40075f..308a56f0b156 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -305,6 +305,9 @@ void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd, > swp_entry_t entry; > > ptep = pte_offset_map_lock(mm, pmd, address, &ptl); > + if (!ptep) > + return; Maybe we should return false and let the caller handle the failure. > + > pte = *ptep; > pte_unmap(ptep); > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index b76a65ac28b3..db2ec85ef332 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -734,6 +734,9 @@ static void swap_ra_info(struct vm_fault *vmf, > > /* Copy the PTEs because the page table may be unmapped */ > orig_pte = pte = pte_offset_map(vmf->pmd, faddr); > + if (!pte) > + return; Ditto? > + > if (fpfn == pfn + 1) { > lpfn = fpfn; > rpfn = fpfn + win; -- Thanks, Qi