Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E337DC433DB for ; Wed, 10 Feb 2021 21:02:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7118664ED0 for ; Wed, 10 Feb 2021 21:02:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7118664ED0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D90936B0005; Wed, 10 Feb 2021 16:02:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D413A6B0006; Wed, 10 Feb 2021 16:02:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C09A76B006C; Wed, 10 Feb 2021 16:02:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id A66A66B0005 for ; Wed, 10 Feb 2021 16:02:45 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 320B518359F4E for ; Wed, 10 Feb 2021 21:02:45 +0000 (UTC) X-FDA: 77803582290.21.cloth44_2f07de727613 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 0E29A180991E5 for ; Wed, 10 Feb 2021 21:02:45 +0000 (UTC) X-HE-Tag: cloth44_2f07de727613 X-Filterd-Recvd-Size: 4813 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Feb 2021 21:02:44 +0000 (UTC) Received: by mail-qv1-f46.google.com with SMTP id e9so1017593qvy.3 for ; Wed, 10 Feb 2021 13:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ENOzr6xjO3GQpgbSD6bbLoPeXooC9WGlpjJfzIMnDjU=; b=eWPMQlwJx9FTsLZHopk9ic4CJOMfVy3EdaxI75SqMMnZ/MxXgBVmjq/OPVeLGBEPNG FRdM9uQJSDBFKKarZP4bsuSFLUGonS5KRxViNDNMoajXRxTuZfdLAbU4YL3YSjQ0mCQj 3MzMo7HB7dpMk4wL0gzf9EFbddo1bHTFff3XXe5FyPujiKDO1i2Tp4MsC+bi8t/Mp1dQ XGVXud+7jAEtKajVRBkq/QObcZ3J+WtlW71TJzMm/Vzjwmy8K55Lpj1gJA03omHlRggS sZgOeI/eJbA18a5U7epZJGvq1TMS+EcRAEmoBF6SNMjaBGaX6EgjnV0PDDhsBD2IFnMT Z7Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ENOzr6xjO3GQpgbSD6bbLoPeXooC9WGlpjJfzIMnDjU=; b=aA9+zm86m0nGKO9xMYinurulgP5ldriwcHYBRf2c5JxaJBd/WeeEtPtEdJtDqEHaIO 8ls3HQQMhufc8eWqMYtdiR+PnLugP0zpU/Cs8xXkyrIQaHMQ1bQMfmGAgA6R5p8s2jWK yAnEdwLkwEOTO6NcGAnDqnsoGbwDKcr9LjBRgQ3G+w7rUZLavzokx4BZvU/qlYKH3pgE lWGBLfPmCMCKsDi0hn2OaNAjnpbmpCLJ21Mf3CmgwHePTW8dsMVEM4b9hYdZiiMV2XLy c8wnCvt1UH5AqakKw25Vw7S6Yc1GPmPKbCorsay24DqNUAdTUATVtKGTN/3S11aVFqSx 1jzQ== X-Gm-Message-State: AOAM533V0jKHSsb31Es7mCOhSDJLkK3RfUpoZPi4MkvOOtmPtn01iTUO hW4NSOxLADym0geFYOc3m+Xacw== X-Google-Smtp-Source: ABdhPJxVTu0NNc1dwqHKIru9SwFEsfLYBP8IqwNRyyTs4tByZCvQcnCyYHh3gdu9CycqQtlKhrtn6A== X-Received: by 2002:a05:6214:c27:: with SMTP id a7mr4541393qvd.54.1612990963899; Wed, 10 Feb 2021 13:02:43 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id 14sm2304346qkr.70.2021.02.10.13.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 13:02:43 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1l9wdG-006F9X-H8; Wed, 10 Feb 2021 17:02:42 -0400 Date: Wed, 10 Feb 2021 17:02:42 -0400 From: Jason Gunthorpe To: Joao Martins Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Andrew Morton , Doug Ledford , John Hubbard , Matthew Wilcox Subject: Re: [PATCH v3 2/4] mm/gup: decrement head page once for group of subpages Message-ID: <20210210210242.GQ4718@ziepe.ca> References: <20210205204127.29441-1-joao.m.martins@oracle.com> <20210205204127.29441-3-joao.m.martins@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210205204127.29441-3-joao.m.martins@oracle.com> 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 Fri, Feb 05, 2021 at 08:41:25PM +0000, Joao Martins wrote: > Rather than decrementing the head page refcount one by one, we > walk the page array and checking which belong to the same > compound_head. Later on we decrement the calculated amount > of references in a single write to the head page. To that > end switch to for_each_compound_head() does most of the work. > > set_page_dirty() needs no adjustment as it's a nop for > non-dirty head pages and it doesn't operate on tail pages. > > This considerably improves unpinning of pages with THP and > hugetlbfs: > > - THP > gup_test -t -m 16384 -r 10 [-L|-a] -S -n 512 -w > PIN_LONGTERM_BENCHMARK (put values): ~87.6k us -> ~23.2k us > > - 16G with 1G huge page size > gup_test -f /mnt/huge/file -m 16384 -r 10 [-L|-a] -S -n 512 -w > PIN_LONGTERM_BENCHMARK: (put values): ~87.6k us -> ~27.5k us > > Signed-off-by: Joao Martins > Reviewed-by: John Hubbard > --- > mm/gup.c | 29 +++++++++++------------------ > 1 file changed, 11 insertions(+), 18 deletions(-) Looks fine Reviewed-by: Jason Gunthorpe I was wondering why this only touches the FOLL_PIN path, it would make sense to also use this same logic for release_pages() for (i = 0; i < nr; i++) { struct page *page = pages[i]; page = compound_head(page); if (is_huge_zero_page(page)) continue; Jason