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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 7B5B2C433FE for ; Wed, 9 Dec 2020 13:43:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 07A4D205F4 for ; Wed, 9 Dec 2020 13:43:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07A4D205F4 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 10A3F6B00F3; Wed, 9 Dec 2020 08:43:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BB946B00F4; Wed, 9 Dec 2020 08:43:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC5C98D001E; Wed, 9 Dec 2020 08:43:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id D2B486B00F3 for ; Wed, 9 Dec 2020 08:43:39 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7F0BF181AC9CC for ; Wed, 9 Dec 2020 13:43:39 +0000 (UTC) X-FDA: 77573861358.04.eye97_4b14279273f0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 5AF4E800CE18 for ; Wed, 9 Dec 2020 13:43:38 +0000 (UTC) X-HE-Tag: eye97_4b14279273f0 X-Filterd-Recvd-Size: 5569 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Wed, 9 Dec 2020 13:43:38 +0000 (UTC) Received: by mail-qk1-f196.google.com with SMTP id 143so1158714qke.10 for ; Wed, 09 Dec 2020 05:43:37 -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=yylzNbuO3wrdbPWHDCfiKVyWlLw4cpAOsa4iJkRVUdI=; b=PdN6SWsvDEVawjC8133CAQVW21onyyKSlnke6p+kBjN3m+mYpYP6OIUL+sOnGnOSEP Y7IWc5SkFkW5nfwfxfvGb/Yzt+bhM7qb06vTBb+CuWHajHe5B3gyACrB4Pp62ao5CUNX zECOB5wd4JpcGw+s8sJbQjmw38VDZOoCSIOHvRQv4mKMVgaOm+QBHx3B8Y7akaiYW7l2 sISCLC+X6z0jnSHWM1hTM3Rz2+ZPRZFV8QHsQOEg3coXlMpS5hwLiUVPqz7us2RCq5Ps XTOoBmQppKycRJphlWlKNT6Rndiv0XhxIsa7auAgwAQK8CluhWO4mLy4hLVTD78z8/qW yEPg== 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=yylzNbuO3wrdbPWHDCfiKVyWlLw4cpAOsa4iJkRVUdI=; b=eFaTqyt2X3TvmS2emJrAf87L6Tlg1SeAEWC7joAIoV6Ay/kB4EGZMY1RtXN9ZczwIj S1b9AxJ2molVIQJ/mP6ulRLjZrgI+lqsxjpmXiV7Lh6LWZ2WYyTQQLEONSJW09O3SRHe Vu08C1cEDdMwDD4sEnnspNmCKqCjuD5Lx0AS2IIEY/Ew5XfsTW0JqLVukx+gVuplj+pY yT3TfbNboQSLfZ4NsjqymBUmczrQeRpZM5wG1aLh8UWZBNgp4q3vzFa/G34LKyR3ys3G VTpjIGr9sOixI1UW9sct0+M/KELkABlqEyZw+8FY37UUIeb+JsqkIAEF7iGU9IptY0Dk mOog== X-Gm-Message-State: AOAM533Nmzh/6/8DVM8MMH+VIACrOeQSvrvKaFn8XhpkM1RhmQQlwe6A KwXSLgOp456p6slrON3PUATBuDbIOwWfLg== X-Google-Smtp-Source: ABdhPJzKSY2/P0F14EY9mrYfPqWoK8uOQ1Vm++VJXHXFv4dMW+SNsiFk0GoOX4jCdDJpmOxHivdN4A== X-Received: by 2002:ae9:e007:: with SMTP id m7mr2833690qkk.416.1607521417446; Wed, 09 Dec 2020 05:43:37 -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 p48sm923647qtp.67.2020.12.09.05.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 05:43:36 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kmzkl-008FCl-Ra; Wed, 09 Dec 2020 09:43:35 -0400 Date: Wed, 9 Dec 2020 09:43:35 -0400 From: Jason Gunthorpe To: John Hubbard Cc: Joao Martins , Daniel Jordan , linux-mm@kvack.org, Dan Williams , Ira Weiny , linux-nvdimm@lists.01.org, Matthew Wilcox , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton Subject: Re: [PATCH RFC 7/9] mm/gup: Decrement head page once for group of subpages Message-ID: <20201209134335.GU5487@ziepe.ca> References: <20201208172901.17384-1-joao.m.martins@oracle.com> <20201208172901.17384-9-joao.m.martins@oracle.com> <20201208193446.GP5487@ziepe.ca> <08d33a4e-5722-6a0a-cca4-9c476afcc228@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <08d33a4e-5722-6a0a-cca4-9c476afcc228@nvidia.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 Tue, Dec 08, 2020 at 09:06:50PM -0800, John Hubbard wrote: > > I suggest using clear language 'page' here should always be a compound > > head called 'head' (or do we have another common variable name for > > this?) > > Agreed. Matthew's struct folio upgrade will allow us to really make > things clear in a typesafe way, but meanwhile, it's probably good to use > one of the following patterns: Yes, this fits very well with the folio patches, and is much clearer > page = compound_head(page); // at the very beginning of a routine No, these routines really want to operate on head/folio's, that is the whole point. > do_things_to_this_single_page(page); > > head = compound_head(page); > do_things_to_this_compound_page(head); Yes, but wordy though > > Is it safe to call mod_node_page_state() after releasing the refcount? > > This could race with hot-unplugging the struct pages so I think it is > > wrong. > > Yes, I think you are right! I wasn't in a hot unplug state of mind when I > thought about the ordering there, but I should have been. :) Ok Hmm.. unpin_user_page() and put_compound_head() do exactly the same thing, and the latter gets it all right. I'll make a patch to fix this > > And maybe you open code that iteration, but that basic idea to find a > > compound_head and ntails should be computational work performed. > > > > No reason not to fix set_page_dirty_lock() too while you are here. > > Eh? What's wrong with set_page_dirty_lock() ? Look at the code: for (index = 0; index < npages; index++) { struct page *page = compound_head(pages[index]); if (!PageDirty(page)) set_page_dirty_lock(page); So we really want set_folio_dirty_lock(folio, ntails) Just like unpin_user_folio(folio, ntails) (wow this is much clearer to explain using Matt's language) set_page_dirty_lock does another wack of atomics so this should be a healthy speedup on the large page benchmark. Jason