Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp722804pxj; Thu, 13 May 2021 15:33:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcKbyjxeHkSFmsq1rQD0HbfiywfCCXACXhUpO26MvsXhQNhZllMzpS8YeACnNt/wfryLXg X-Received: by 2002:a17:907:ea0:: with SMTP id ho32mr20166412ejc.396.1620945231247; Thu, 13 May 2021 15:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620945231; cv=none; d=google.com; s=arc-20160816; b=H1DVUT9X7jDlZwNHGszkrbEuIFoWZp1zScUqlGdmQcQ3EHJJ+Dan8L4cn8tx3WL77b 8bYmhtt+uXOGgNI/MnuiD4bmfjsKNMar7K0JqX8TNi5OSaqOBzdbtZYDhu5Ep3AHp9/X bIr9C0LWUEtvZspD/Lvf7xBRTV+2ANYsQyCKfO8zWmTQ1ZqAUVsmwMJa2h8vvhbn7be6 jQ9VW8TpoXpEUfSSoYHnjc0npDIF002/0GvBQKReWyGIhbcZMNfOeI7iECYQAJ25uh93 AwgqPb1JiUtuPoVA5eQgt+qKyOQWCIlaZzcVrEwiMr7smiJprweWEqcLD3kyDv+ofUTw 10Yw== 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=H1NmysONfH93wRxMzbKIRXMjO3sQy9N1aOQConHhku0=; b=wqsKjjWP7d43cW9NflsL/uhKkDa50mfQnLdwVxeoKSC5rPGTgNo9sQzzKUwMC0iHxB cqMpl1hLRxAes/e3LrfakhimJDTs8EE0aHc3hdXRNllbZK4DSYvNFHI6Sh1dIQpnAqiC mzPIXB4G5+f4W/NTmz6h6hDpuMV3wY8KjJJ4nOSjcYiCRLDIeyQN4GI/EjThGCL7I1Qr hB9wesL53wbpsVw0ne/in1wVKtGmCXwKvZOxtkA+pW2q+tnR/oIzffd23vJbQut1lGHR Ed2TZM9YsaUOxS63szeVPs8F+C2aKj2sM0k/52AFgPRH2F85qkXRxTHBkbcrEcaZsCww Sh1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=j0U7U0Kx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a10si206586edq.515.2021.05.13.15.33.23; Thu, 13 May 2021 15:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=j0U7U0Kx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234619AbhEMOzL (ORCPT + 99 others); Thu, 13 May 2021 10:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234823AbhEMOwh (ORCPT ); Thu, 13 May 2021 10:52:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50993C061346; Thu, 13 May 2021 07:51:26 -0700 (PDT) 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=H1NmysONfH93wRxMzbKIRXMjO3sQy9N1aOQConHhku0=; b=j0U7U0KxCjG8TbXLUokLW8ygK4 unQ5UMYf+It+N2ARfOjZrJUGd7raTpl84OmLbbydENw/nOS6I/ySHPrIBlTK86QPnCnT94yZL6lSY VCTmecp5NB+CiHdvaxcktwj55f2yaubMcP/6DD/23YUZ6z4xyk5FthNt7tHt6Skbas0IcEdD6D9fX WoxcuTkvUkO3e+w3qCeEqpHjXGt+X/OLX1t9sHVC9286L4izzDh1/EGdDGLQKESrIVIQ5Swz1T6TZ /RdWq8rD4m7LYJ5mwp1sRhlEPvk6v9rPITP6/Ch/Qn1NQ7q8FwC0xZAJhkTzR+lfcNx0H3oEMM+ip i/bpWC5A==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lhCfh-009W9H-1T; Thu, 13 May 2021 14:50:52 +0000 Date: Thu, 13 May 2021 15:50:41 +0100 From: Matthew Wilcox To: akpm@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 00/33] Memory folios Message-ID: References: <20210511214735.1836149-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210511214735.1836149-1-willy@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 11, 2021 at 10:47:02PM +0100, Matthew Wilcox (Oracle) wrote: > We also waste a lot of instructions ensuring that we're not looking at > a tail page. Almost every call to PageFoo() contains one or more hidden > calls to compound_head(). This also happens for get_page(), put_page() > and many more functions. There does not appear to be a way to tell gcc > that it can cache the result of compound_head(), nor is there a way to > tell it that compound_head() is idempotent. I instrumented _compound_head() on a test VM: +++ b/include/linux/page-flags.h @@ -179,10 +179,13 @@ enum pageflags { #ifndef __GENERATING_BOUNDS_H +extern atomic_t chcc; + static inline unsigned long _compound_head(const struct page *page) { unsigned long head = READ_ONCE(page->compound_head); + atomic_inc(&chcc); if (unlikely(head & 1)) return head - 1; return (unsigned long)page; which means it catches both calls to compound_head() and page_folio(). Between patch 8/96 in folio_v9 and patch 96/96, the number of calls in an idle VM went down from almost 7k/s to just over 5k/s; about 25%.