Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2703660rwd; Mon, 15 May 2023 15:55:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hKGaTS56tEUTv0+w0G9jsg8djzXDASOq2gT2DbF2rN3GBKGlVEZcYIAxGkUxVBlcLDyh9 X-Received: by 2002:a17:90a:fa92:b0:24e:225b:c1a1 with SMTP id cu18-20020a17090afa9200b0024e225bc1a1mr35549681pjb.32.1684191350741; Mon, 15 May 2023 15:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684191350; cv=none; d=google.com; s=arc-20160816; b=uIm/5eTJ/v836Fnu7kUvQzt/Y9h+ulVssS5SJYbgmTDcehMi1onQhvxTrZjKOYyx+8 qzShgcO8KQNUdh87Ojzhgbp+tj0R1VRDShbfvL2AFkjA3waGtvTJZkVDgA/SbyNz5ZSN 9xHSn1YkBXTe8HQS43iyrzuEHAKv6/EifUk22rvCvyJwiLG4P3NETY7wtdHp5fuggnSf YuB+XpB1dsD8/eDWgmUYTvtAMyJUZJbf8dgKo+wYWjwYwIjDFlI7tfoX3s7yK4OtoEnm OtFhvbevUMdCfm486XaVxYnuAK3BercnlnOA6SJ0G5YKRmJw5BQN1h1f5YjD39FAGlre JVlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mJEVFLdRPcjN80hZWVkTiTXZUJ1+07IKEu73jeobqWc=; b=WQjcU0ZoAnreipNBqln9EDyxhwg0bbKS+0uwtKVahFtRgmcxyfIgTEpjFJSAM6N8/8 KP0q5ZM+5rg3LqTDsV+LFQpNF6joCyWceQJrSNZschQsN9zwB7kkE6L0HdkB6NfGj+1m UvXXekJWG2VqmbYXXqmfrVDxT2mJtz2MDueitUAUXyxSAOUYno64TCxUSa9DRzxfwgLz EloPhQqVIsbfcFgegQ+53tC5L33i1IXN1RcTkZsqkjI46utEqoL+Fx098gxWNdR4HwW6 h3+RIP012LUgIysi+1KjcbvCfyf34v/FBk3QYE0WnCs7zVJb7r2Uyq2E7UX2zbrHsjM1 4FVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CiiSwhTf; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a63af52000000b00530b3b5ec09si6907711pgo.225.2023.05.15.15.55.36; Mon, 15 May 2023 15:55:50 -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=@redhat.com header.s=mimecast20190719 header.b=CiiSwhTf; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244867AbjEOWI2 (ORCPT + 99 others); Mon, 15 May 2023 18:08:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242789AbjEOWI0 (ORCPT ); Mon, 15 May 2023 18:08:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFFD18A7B for ; Mon, 15 May 2023 15:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684188363; 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=mJEVFLdRPcjN80hZWVkTiTXZUJ1+07IKEu73jeobqWc=; b=CiiSwhTflptjEBcLEbSNcxRj7RGU90dDNSGjeEyX/TYvAM4kbqE3jaB/r3JKxuRlCW/KO2 WAhPrebDUhCZJdNnJuzX3HFPeXHmM03vAyzu/5l1Kwx77FgOP4rH/gy0MDO4KKlfQtkgaS M5ph4nlD4Gj+cSNvFAKFYwgMpls6kPw= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-xSVJpvM3NsOi_V0dzNT-mg-1; Mon, 15 May 2023 18:06:01 -0400 X-MC-Unique: xSVJpvM3NsOi_V0dzNT-mg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-5ea572ef499so20939896d6.1 for ; Mon, 15 May 2023 15:06:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684188361; x=1686780361; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mJEVFLdRPcjN80hZWVkTiTXZUJ1+07IKEu73jeobqWc=; b=kLzeLtUQAUYnGNfXvxC2bwOVxErcYSzdUhL8jLJbTcYZdIf2DlYMW0pOoD5xLEpMCj 8Z/8zDFf1dP5Q9c7CLzP+j2fkTPjbq94H25MGw98PvgmgYYQGorccI75Vtd68NIWCmIB 2JGR4cCfA0AyKNsH0rFnFenHdgl5GhEDTvCvnZEcRCaUYQzL5J0qgHZNYeqWrOeGqdbs E4V5hHxyqjb9lL83OQN2L/WRccX/UYK1ZINBUK1fZgsk7IkTPJ5ycHlC9dwDZhhC2zB+ KV/uzH+6V3WwVsrJ3XWshhDvBNWpe2CBlhxiuyeAZn+8bDDk1PdkV9A/KyNX9YxdTKxE nD7A== X-Gm-Message-State: AC+VfDymZxILf4uV2s+pweyJSjASN6knUTfkeEZz5ukGyOk0zNGWuZah LdpdPVscHszyBCq1fgnhtGHr/wu8wgpq1CJhFPoAtF45dorZ90DuGNWYqaLWn3L518RkJ4hVXGs PwSr/yxO9U5fRGpEwVjQ+criD X-Received: by 2002:a05:6214:519a:b0:61b:76dd:b643 with SMTP id kl26-20020a056214519a00b0061b76ddb643mr16092578qvb.4.1684188361049; Mon, 15 May 2023 15:06:01 -0700 (PDT) X-Received: by 2002:a05:6214:519a:b0:61b:76dd:b643 with SMTP id kl26-20020a056214519a00b0061b76ddb643mr16092547qvb.4.1684188360785; Mon, 15 May 2023 15:06:00 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-62-70-24-86-62.dsl.bell.ca. [70.24.86.62]) by smtp.gmail.com with ESMTPSA id i7-20020a056214030700b006215f334a18sm3542109qvu.28.2023.05.15.15.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 15:06:00 -0700 (PDT) Date: Mon, 15 May 2023 18:05:58 -0400 From: Peter Xu To: Yuanchu Xie Cc: Andrew Morton , "Liam R . Howlett" , Yang Shi , Zach O'Keefe , "Kirill A . Shutemov" , Matthew Wilcox , Pasha Tatashin , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: pagemap: restrict pagewalk to the requested range Message-ID: References: <20230515172608.3558391-1-yuanchu@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230515172608.3558391-1-yuanchu@google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 Tue, May 16, 2023 at 01:26:08AM +0800, Yuanchu Xie wrote: > The pagewalk in pagemap_read reads one PTE past the end of the requested > range, and stops when the buffer runs out of space. While it produces > the right result, the extra read is unnecessary and less performant. > > I timed the following command before and after this patch: > dd count=100000 if=/proc/self/pagemap of=/dev/null > The results are consistently within 0.001s across 5 runs. > > Before: > 100000+0 records in > 100000+0 records out > 51200000 bytes (51 MB) copied, 0.0763159 s, 671 MB/s > > real 0m0.078s > user 0m0.012s > sys 0m0.065s > > After: > 100000+0 records in > 100000+0 records out > 51200000 bytes (51 MB) copied, 0.0487928 s, 1.0 GB/s > > real 0m0.050s > user 0m0.011s > sys 0m0.039s > > Signed-off-by: Yuanchu Xie Acked-by: Peter Xu -- Peter Xu