Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4715777rwd; Tue, 23 May 2023 11:21:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6iQHV87k7CbRJN3kcihE3zm9h5YLkztslNRxJH2xurT0jnVySeHVp8fz3qHxKHFcCuCC7d X-Received: by 2002:a17:902:d345:b0:1a2:6257:36b9 with SMTP id l5-20020a170902d34500b001a2625736b9mr15536196plk.31.1684866085886; Tue, 23 May 2023 11:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684866085; cv=none; d=google.com; s=arc-20160816; b=nZZYs3qg5eLJgvU3X/NTI9alycX5AG0SXo5oxy5Vxd7AE6fmb+tRZPjmUo8wzBsqlo Tr6CJPl+Ktp4tquzBeZAPZs3eQhjUDiI1G60gTgioC2YFcjw1dAYHzQrp5Ep2nQSG1CR g7o8bx5mF0nw4VWx8tmXpLzmw9r2ctqlzO+5pa3KMfe67JmiSebhlVMMkXhYNeisoD2g 5l1uMCm8fo4bSvzy3ndl6z7rSI1C6TC7qFXaFyoLnz/KcFxWZadjVBM9d/KvHRtyFwmk 5/T5QVnTpzhrHiV8MYa9lQuc6AmJFfNc30nHjowpanwXpgDB9iyzq71nvbNnWr7luB5O k9eQ== 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:date:subject:cc:to:from :dkim-signature; bh=vf0CeHiZpGPAyht1SjRfwg3G9Uc5t2LEXFJN3uhuRJY=; b=wnVg714d0d1wtuCpE7oeuTj9+0WPCEUcjMtt2oMgTGTPmaPvtBXFXg7dTpHFeomCEw VAsRGWTlPekFly8Ob2GnvO1iPVlh9fXvlsYZbKX9dyhCOkfemZgK7ETOOHSznNhCbwCc H7FPF3AULgQqRorgtsqkfxacTNLXUURsQRFEAKDHQw/CcXAWiMaY7XmPwKlFTMsSXY7J +FCloGEDybVYMI5t285jWs8EYKOobTy1dBK5If34xIbnAOkzQqMMgINN/2xF2DtVbaBK tVYTfuvWWYvk1lesEbjm/fURH7fSd2Cs00FftyoiAmM+Lpzujp4GLZkPD0mmIQo8jhZP Ngvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ff5mtWAR; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id km3-20020a17090327c300b001afcff6d242si1382432plb.531.2023.05.23.11.21.12; Tue, 23 May 2023 11:21:25 -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=@kernel.org header.s=k20201202 header.b=Ff5mtWAR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238147AbjEWSHL (ORCPT + 99 others); Tue, 23 May 2023 14:07:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238132AbjEWSHK (ORCPT ); Tue, 23 May 2023 14:07:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14EC1C5 for ; Tue, 23 May 2023 11:07:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A12466198E for ; Tue, 23 May 2023 18:07:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64EB0C433EF; Tue, 23 May 2023 18:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684865228; bh=PqO2Ba0azEpR69b5p3AcZhVRdxUYPoFaydPljsZiJ08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ff5mtWARZiVsUDm26jYK2NzJV9heOhVdPVGG+GTPzayA+f7KaErquj7YpGPB0tqnS 8Xjw8GhtAZoYaxeEkk/AEcjmW/NpoAe2fjEVBqOy8mDia04zoW/JpOuXzj2QI743Uv 9fg6oXsf99r8rUYjCpbg8WI8E9A4WKITgvK7QQeJO288u0zVR4YCmT4QsbIP+u5Ekj rJxh6oqNS4wCciLQ/4lBz+Xth8Y+V1AubibKcVUGOLYnBDsXsX7KkzpgydzrytMOz+ zgbX2bUTcZ1MD55KVvsL5IBsmReg4CzPE64MeTLF1jtoVVGqC94QbNhjfIhxHZRk3S 5K52MBWNo9fqA== From: SeongJae Park To: Hugh Dickins Cc: Andrew Morton , 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 Subject: Re: [PATCH 09/31] mm/pagewalkers: ACTION_AGAIN if pte_offset_map_lock() fails Date: Tue, 23 May 2023 18:07:03 +0000 Message-Id: <20230523180703.89902-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <6265ac58-6018-a8c6-cf38-69cba698471@google.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Hello Hugh, On Sun, 21 May 2023 22:00:15 -0700 (PDT) Hugh Dickins wrote: > Simple walk_page_range() users should set ACTION_AGAIN to retry when > pte_offset_map_lock() fails. > > No need to check pmd_trans_unstable(): that was precisely to avoid the > possiblity of calling pte_offset_map() on a racily removed or inserted > THP entry, but such cases are now safely handled inside it. Likewise > there is no need to check pmd_none() or pmd_bad() before calling it. > > Signed-off-by: Hugh Dickins For below mm/damon part, Reviewed-by: SeongJae Park Thanks, SJ > --- > fs/proc/task_mmu.c | 32 ++++++++++++++++---------------- > mm/damon/vaddr.c | 12 ++++++++---- > mm/mempolicy.c | 7 ++++--- > mm/mincore.c | 9 ++++----- > mm/mlock.c | 4 ++++ > 5 files changed, 36 insertions(+), 28 deletions(-) > [...] > diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c > index 1fec16d7263e..b8762ff15c3c 100644 > --- a/mm/damon/vaddr.c > +++ b/mm/damon/vaddr.c > @@ -318,9 +318,11 @@ static int damon_mkold_pmd_entry(pmd_t *pmd, unsigned long addr, > spin_unlock(ptl); > } > > - if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) > - return 0; > pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); > + if (!pte) { > + walk->action = ACTION_AGAIN; > + return 0; > + } > if (!pte_present(*pte)) > goto out; > damon_ptep_mkold(pte, walk->mm, addr); > @@ -464,9 +466,11 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, > regular_page: > #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > - if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) > - return -EINVAL; > pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); > + if (!pte) { > + walk->action = ACTION_AGAIN; > + return 0; > + } > if (!pte_present(*pte)) > goto out; > folio = damon_get_folio(pte_pfn(*pte)); [...]