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 B55AEEB64DB for ; Wed, 14 Jun 2023 03:58:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED3828E0002; Tue, 13 Jun 2023 23:58:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E84586B0075; Tue, 13 Jun 2023 23:58:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4B1B8E0002; Tue, 13 Jun 2023 23:58:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C5A286B0074 for ; Tue, 13 Jun 2023 23:58:40 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 90DAB1406FD for ; Wed, 14 Jun 2023 03:58:40 +0000 (UTC) X-FDA: 80899996800.04.3C53868 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by imf14.hostedemail.com (Postfix) with ESMTP id C0D60100004 for ; Wed, 14 Jun 2023 03:58:38 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=y+wiz6YE; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686715118; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=32HdmVOewK5uBWcPqCzKK7B9PyAlOQ6MrudxZirB7g0=; b=wbN7eUEt8+zHC93s5u5/6Dwh4Vy/UA0i3exi5tbFu3aVan0zydzjqmowBCEf5kHhb2CUW/ OUM7V3Fuk2tiJ4jzE3ofIn4FZyOfdFLnxawQ/fZnY51oFx2JfoDd1OnhT2f7DVs0IGxtb0 JREz6INAEBYmQMC0PYkdVWpaKiMJ3+s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686715118; a=rsa-sha256; cv=none; b=L/yuZPrkS+8uZ2YkuvsLua/1KSBWTt0pRhHwW03SBgq7FQF1LpKbjZ1YSw7kM2aGdESG1D lQxzQa1Oa11WL0LBsGLk0sO5X7s1+RikpbZbZJj1gvsrUi8sp+aXSpiw3SCthtmgQJW7/7 1pbDdBSmCmCDRjQPJ0LaY1ZQuzh7/xM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=y+wiz6YE; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-bc50b217bc0so248626276.1 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=LK0/9vC3G23JX3PWYx4uz+mT1xCcehZTNPkvcPN0JGN5+yexRmTKhAmQr+Jh0d/3AD 3zRoI3orTvMJRSQWQYjlvGrVd4ULzFULL78UcrOatH96tnvyQdYq8MXAcc6rjPTXl4x6 jftmdqT/5luPNAEIeKCpKfgAcT62+KBJTobe0ZAuefPzXd2BDKULgmJ938ft+IlAtMNN UGgkvOHc8oh/hMJmVLXtx9RnO6oGl3xySVYh11QK/VHbFsuyp6t+b73+ZO/gGnfkEHTP PI6HiHWSlvqsHUQkc+L5RMNMLVOh3QpXgEQMW7Vp0TcXul1/yvfD23Sxbj9vbDnyAyGb +zgQ== X-Gm-Message-State: AC+VfDyQ6g+zTM98gfv5d244DVgNeStSvsYbhxQIPbK11EltrzZcHOkG lNwZ1epE6Dq5WMJocAFBw7BfMA== 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 X-Stat-Signature: w9onb74k4gh5x5af6gmnee5kwnpeer34 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C0D60100004 X-Rspam-User: X-HE-Tag: 1686715118-790434 X-HE-Meta: U2FsdGVkX18HLEkRBD4fKSp1+Sw1KG7K8dYb0DEwJk6+I1sc1cTG5tioDZ0xKmhRXgOjMMy0VY0tbAp+5YOE57lebQyC27LqQg0aub8x7YuBOWQWtWF2JfxgZBx49rIoMFa4JvS9w4YUkrhE6oXkdgqqOGc8rMOcj5uE4oDS+OetOtjlVK5eGkBATHrGCwMOvqpj/Iw5dWxykKGLsdb4xPeXSC5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M3K4ybv7lGQ3H4uxDiDJZmNYyUFSMINVxxmcpV5pneRLtNjhBrIPCHPZgoEnMX6d91hMzXEC+4wulCWs6LZxgKm+mLznBuLGqx1bCLNEs3O23mQebI/7C9U51pOVL7pigsvGRLQcTHTE= 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 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