Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp941815rwb; Thu, 10 Nov 2022 09:09:46 -0800 (PST) X-Google-Smtp-Source: AMsMyM7nXwh2a2ydwfgWlq/vfXp3+YOf2XSGjMjOlNxMAOudwa2rvy58OlqhlFr9so5AF/zHPFPs X-Received: by 2002:a17:902:8693:b0:17a:f71:98fd with SMTP id g19-20020a170902869300b0017a0f7198fdmr65388775plo.25.1668100186741; Thu, 10 Nov 2022 09:09:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668100186; cv=none; d=google.com; s=arc-20160816; b=vomrQMjZ9jzO9ze3EmLBiNg0XJ7e1I/i9QB5BKcLzuWCulMpAv+NT7UFkhxBuzaImQ JuvgkYXjoXXw3QbUqDYCAv5Gc89/wXlkHigYXJsz1iM5gCMUEO9v1slC8GNhIjFqFLf8 kR57QLRyu9YfLegd9OeQrtMzNqhMVDcIBo3Zzps+ReqP3eDvZ48LKe6pHUSUqYC7WLLp se8C97wF1S1BYElGy8ubYGPdBK4upFW+HWA2S57eoIOEN+9qiVLi2H2TO2CHla6yShIR wHj2/IDVdDCy3cBI7lauS07P9L55bHCqp8Zf9JCyvW4ao8qatvOCzBCEznGOEtZgDalP qfDA== 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=NPEF063H+Y7JeJNfnAB1kp+fd1pLsT9ML+6VjdUPh7o=; b=lQ+6Mz6ifsCYwqwXiYbUPB1N88nJQYc46ikOkzA3tU4SYVI7EguhDlXTjwG2belgqE OATUcR4I9QZF/Wr7UYp5fVn+TcB8DeKtR+D+eN/mvHzYiBw2lz6zJGebaF+MO7eE5yaL Um4B26104ULRnKl+uXuftJjbJJ4m3ZnGFmjTjNj94s2UNQNESFL1eujtNV7eBlvIIoPD Ny2dfC3oMKKvij5j+l48NBmYBQEhkZ4NybrW74YWmCJz6CdJx2uMAhpV6WiyVLbEH+f/ kNPg5NFZHW8SFkz2LRZ8XFzdPZj4TkG8OFEc7dPFwxfME9q+T0brIB+73O7sl4s31gzX ZtVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=mx+EY9CO; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a63f852000000b0046fd4b828b4si18650631pgj.354.2022.11.10.09.09.30; Thu, 10 Nov 2022 09:09:46 -0800 (PST) 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=@infradead.org header.s=casper.20170209 header.b=mx+EY9CO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbiKJQcR (ORCPT + 92 others); Thu, 10 Nov 2022 11:32:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231670AbiKJQcJ (ORCPT ); Thu, 10 Nov 2022 11:32:09 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D83163FBA3 for ; Thu, 10 Nov 2022 08:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NPEF063H+Y7JeJNfnAB1kp+fd1pLsT9ML+6VjdUPh7o=; b=mx+EY9COzoDzeuy2+0heRU2yNe yzX/vmiC19SUiPXxXDe3Mld28kvj/feSddm0YDw9iYaoR6cFptf4oO6yG82v/riN6Wpid4/0SRwQl zoOCHLqUuayVhzSFL6UbBwFSp6aZgG6Tb1dHoy0X72Ced80huuiy8/kMhkeaeH5LT47Jc4CoDZB1T mA+DweHo/jN0Rlhgnyde/Z0ueQJn3iMdcvqFEG2W66SIEdiQxy2oinLi/WkRa3UmvD8cFjFfFsRPH tp+x9oFo59yFei677vlB7qS8S/c2iCw3nDiN9eDPQftxhpdbchYaCJjS8hwCKiFm3t6iqIpCkjLS1 W2XpdHBQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1otASt-00CD9f-Ff; Thu, 10 Nov 2022 16:31:43 +0000 Date: Thu, 10 Nov 2022 16:31:43 +0000 From: Matthew Wilcox To: Linus Torvalds Cc: Hugh Dickins , Andrew Morton , Johannes Weiner , "Kirill A. Shutemov" , David Hildenbrand , Vlastimil Babka , Peter Xu , Yang Shi , John Hubbard , Mike Kravetz , Sidhartha Kumar , Muchun Song , Miaohe Lin , Naoya Horiguchi , Mina Almasry , James Houghton , Zach O'Keefe , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 4/3] mm,thp,rmap: handle the normal !PageCompound case first Message-ID: References: <5f52de70-975-e94f-f141-543765736181@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 Wed, Nov 09, 2022 at 07:23:08PM -0800, Linus Torvalds wrote: > On Wed, Nov 9, 2022 at 6:18 PM Hugh Dickins wrote: > > > > Commit ("mm,thp,rmap: lock_compound_mapcounts() on THP mapcounts") > > propagated the "if (compound) {lock} else if (PageCompound) {lock} else > > {atomic}" pattern throughout; but Linus hated the way that gives primacy > > to the uncommon case: switch to "if (!PageCompound) {atomic} else if > > (compound) {lock} else {lock}" throughout. > > Side note, that 'compound' naming is also on my list of "I'm _really_ > not a fan". > > We actually have a completely different meaning for PageCompound() > than the meaning of 'compound' in the rmap functions, and those > functions literally mix those meanings if not on the same line, then > at least right next to each other. > > What 'rmap' actually means with 'compound' in the add/remove functions > is basically 'not PAGE_SIZE' as far as I can tell. Ah. I've been trying to understand what that 'compound' really means, and what the difference is to 'PageCompound()' and why we need both. Thanks! > One reason I find the "compound" name so horrifying is that it is used > very much for HUGETLB pages, which I don't think end up ever being > marked as PageCompund(), and which are - for various historical > reasons - doubly confusing because they use a "pte_t" to describe > themselves, even when they are actually using a "pmd_t" or a "pud_t" > to actually map the page. HugeTLB pages _are_ marked as Compound. There's some fairly horrific code to manually make them compound when they have to be allocated piecemeal (because they're 1GB and too large for the page allocator). > To make things more confusing, some places use PageHeadHuge() > instead (but the folio version of said test is called > "folio_test_hugetlb()", just so that nobody could possibly ever accuse > the HUGETLB code to have consistency). That one's my fault, but it's a reaction to all the times that I and others have got confused between PageHuge and PageTransHuge. I suppose we could do a big sed s/PageHuge/PageHugeTLB/, but I'm hopeful the entire hugetlb codebase is either converted to folios or unified with THP handling. > I do wish the HUGETLB case didn't use 'pte' for its notion of how > HUGETLB entries are mapped, but that's literally how HUGETLB is > designed: it started life as a larger last-level pte. > > It just means that it ends up being very confusing when from a page > table walk perspective, you're walking a pud or a pmd entry, and then > you see a 'pte_t' instead. Yes, one of the long-term things I want to try is making the hugetlb code use the pmd/pud types like the THP code does.