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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F704EB64DA for ; Wed, 14 Jun 2023 03:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242578AbjFND7A (ORCPT ); Tue, 13 Jun 2023 23:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242477AbjFND6m (ORCPT ); Tue, 13 Jun 2023 23:58:42 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A61211BD3 for ; Tue, 13 Jun 2023 20:58:38 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-bc5566538fdso255539276.0 for ; Tue, 13 Jun 2023 20:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686715118; x=1689307118; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=32HdmVOewK5uBWcPqCzKK7B9PyAlOQ6MrudxZirB7g0=; b=y+wiz6YEOG+gFWvGvLIELTfeOFEEjmj6VmaR4l5TEimPZrrRLWRSt67ByLkFBEMR+v bCP9oADXmuV0X+UBXpkPh4CBHLVb9CeP7vecSyHdtjJV2q0LIZM6RCX3/ZfE6OLeWFuI RiYBtFemg/LsWw9EhkVn/sj3pOi+OiGTz8E7ryhSTLpImY9d2aChiJnI96YcSsN8AOPd hjqxszOZWh9Q2sMO5YuVZzDVyhYrY/tnHRLv39XACFcZROvrM2V8a8bWDGtUlzxxP5x2 TRoeM13pnRcG1mCAxxo6J+bKVlILKRbVPh5FsuLuBv2UjtpOiUABzvEcJZliHrpOEVfZ D1FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686715118; x=1689307118; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=32HdmVOewK5uBWcPqCzKK7B9PyAlOQ6MrudxZirB7g0=; b=Ealp4TRVMK3/XDV9hFPeFvpRDnl4Tp+zoaLL7mZaewl7QhvxElaPG2bbJmskfxA1ME WOOnbJCRIFYc7aZO3ZavQxlX7Ve4MEgs5b6T1mejOnHDyKInacz/O5HpFGzWiDMGKtrF 8qQ5g3ct6aajklA6Q9MRctPH/pgeWcAIEJJXcmLJH9bOGSFLE25vNGQ4NxoFXUtRrN8q RRENIJH6r96TEWwW6OsvW0h89ygm8Y69Y4McdpRVgGwYvNe4u2NBe3FO6ovG6G8F9BMK JdnJOWhHkhP2/b6OQIAi5elkRrzeLT0vokMHIncOjinzPqnqy4kBt5iDN4s0dk95R+h2 L+yg== X-Gm-Message-State: AC+VfDzFZraejVzXdJrwvdbdmDwhNiZZLuE82ZLkKe25xaGpFn/bD5hJ 46+nOW6Xidu4djg/WKw1/52qww== X-Google-Smtp-Source: ACHHUZ5QJxsmW1EPJI5lNLxk67iObZwfxlfltjicyCutkDlAJrrC3Q1bCfMXk/s/5Zo1o/n8QLEDXg== X-Received: by 2002:a25:ec0d:0:b0:b9e:2b25:be56 with SMTP id j13-20020a25ec0d000000b00b9e2b25be56mr899743ybh.32.1686715117548; Tue, 13 Jun 2023 20:58:37 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id w188-20020a25dfc5000000b00b923b2935d9sm2143983ybg.20.2023.06.13.20.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 20:58:37 -0700 (PDT) Date: Tue, 13 Jun 2023 20:58:26 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: "Huang, Ying" cc: Hugh Dickins , Andrew Morton , 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 , Lorenzo Stoakes , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 31/32] mm/swap: swap_vma_readahead() do the pte_offset_map() In-Reply-To: <87legp6rax.fsf@yhuang6-desk2.ccr.corp.intel.com> Message-ID: References: <87legp6rax.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 12 Jun 2023, Huang, Ying wrote: > Hi, Hugh, > > Sorry for late reply. Never apologize to *me* for being "late" or "slow" or "unresponsive". Thanks for looking, yes, it was indeed for this one that I particularly added you to the Cc. > > Hugh Dickins writes: > > > swap_vma_readahead() has been proceeding in an unconventional way, its > > preliminary swap_ra_info() doing the pte_offset_map() and pte_unmap(), > > then relying on that pte pointer even after the pte_unmap() - in its > > CONFIG_64BIT case (I think !CONFIG_HIGHPTE was intended; whereas 32-bit > > copied ptes to stack while they were mapped, but had to limit how many). > > > > Though it would be difficult to construct a failing testcase, accessing > > page table after pte_unmap() will become bad practice, even on 64-bit: > > an rcu_read_unlock() in pte_unmap() will allow page table to be freed. > > > > Move relevant definitions from include/linux/swap.h to mm/swap_state.c, > > nothing else used them. Delete the CONFIG_64BIT distinction and buffer, > > delete all reference to ptes from swap_ra_info(), use pte_offset_map() > > repeatedly in swap_vma_readahead(), breaking from the loop if it fails. > > > > (Will the repeated "map" and "unmap" show up as a slowdown anywhere? > > If so, maybe modify __read_swap_cache_async() to do the pte_unmap() > > only when it does not find the page already in the swapcache.) > > > > Use ptep_get_lockless(), mainly for its READ_ONCE(). Correctly advance > > the address passed down to each call of __read__swap_cache_async(). > > > > Signed-off-by: Hugh Dickins > > --- > > include/linux/swap.h | 19 ------------------- > > mm/swap_state.c | 45 +++++++++++++++++++++++--------------------- > > 2 files changed, 24 insertions(+), 40 deletions(-) ... > Because we don't deal with PTEs in struct vma_swap_readahead anymore, it > appears simpler to record addresses directly, for example, > > struct vma_swap_readahead { > unsigned long start; > unsigned long end; > }; > > we can make ra_info.win to be the return value of swap_ra_info(). > > Anyway, this can be a separate cleanup patch based on this patch. Ooh, that would have required me to think, rather than just delete lines. Mmm, if you see a cleaner way forward, yes, please do add some cleanup on top. > > For the patch itself, feel free to add, > > Reviewed-by: "Huang, Ying" Great, thanks a lot. Hugh