From patchwork Tue Apr 9 19:22:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13623118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9945CD128A for ; Tue, 9 Apr 2024 19:24:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 678B46B008C; Tue, 9 Apr 2024 15:24:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6285A6B0093; Tue, 9 Apr 2024 15:24:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 516CA6B0095; Tue, 9 Apr 2024 15:24:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2FD086B008C for ; Tue, 9 Apr 2024 15:24:10 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 92CCBA0569 for ; Tue, 9 Apr 2024 19:24:07 +0000 (UTC) X-FDA: 81990968934.07.C583253 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id E7D17160017 for ; Tue, 9 Apr 2024 19:24:05 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HbQ8J0GV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712690646; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=omUW48lRIosbAMPj8czTvBZpGDzoyoLuJmkkL5iPx/s=; b=GaJ+WLNBFW5A8IKlgpEfvxfnIDQM5O/Lk+BSoBUnyrqjvG193SD+hibbY3N2lkGRofXan+ Ydt3fh7bzwwpqiwjz5EcZ1c1kdDuEGnnkAhisIjHd3pBwPu3ZRT/mp9rUo3rhrkTmmkyuG SFBOO2/B9eQb6PvMGiO+NbKRMCVTVUY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HbQ8J0GV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712690646; a=rsa-sha256; cv=none; b=Sa84EiugOFXl2auS5b85BmM4xHKWTnHyTufJBhc7l0YkF2fr1doa1TJOEFCBFIVIRJVMf9 5oBse5HOvv967NwN9zmmES5F+E6k5vBPWq7NRwqG3xPM3/qGim2RS3dtyBk76SVulc99Xc NzEXZZSlBzssXBiAKhmTwmucC8TLV7s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712690645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=omUW48lRIosbAMPj8czTvBZpGDzoyoLuJmkkL5iPx/s=; b=HbQ8J0GVQ8w2hxM+l8xHn5f/aM3NCN/vVYt1YDiia6yh7QE1MQIbBw+wR4ugI2dOXoN/gz l94dlY053kZ6Ytb+O+HzXC8gu7FS/wmcAewPTAJjcFVoL0cGoNjN/FV9v6n/Uq/W2n910y Fz/RF4T0+y65GsyBL2zg7g0pRXNVG+8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-312-_0ZSgaEpNaK-itip1P_sGw-1; Tue, 09 Apr 2024 15:24:01 -0400 X-MC-Unique: _0ZSgaEpNaK-itip1P_sGw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DE82338000A3; Tue, 9 Apr 2024 19:23:59 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D8CB40AE78D; Tue, 9 Apr 2024 19:23:48 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Hildenbrand , Andrew Morton , "Matthew Wilcox (Oracle)" , Peter Xu , Ryan Roberts , Yin Fengwei , Yang Shi , Zi Yan , Jonathan Corbet , Hugh Dickins , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , Chris Zankel , Max Filippov , Muchun Song , Miaohe Lin , Naoya Horiguchi , Richard Chang Subject: [PATCH v1 02/18] mm/rmap: always inline anon/file rmap duplication of a single PTE Date: Tue, 9 Apr 2024 21:22:45 +0200 Message-ID: <20240409192301.907377-3-david@redhat.com> In-Reply-To: <20240409192301.907377-1-david@redhat.com> References: <20240409192301.907377-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.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1pXuUfved6H0RiZFnI9EPy0 MFYeslFG /u+S1YqftZx9zDf+lUVxlWDcpVuQUpUvGHjnaquflc/xzFmHwgEgmdKMzCg7KlOdxiyZ8dg5eSPLL7CnHTXhA3qrGchFLDSlWOaWa/45Fv99S37+KWHcHUcRzyxxz/zYxsdiurRZAAfCHd2Dt5Mc9NRMxqM7pgq2dWUeckg6SSQ8Vfwo= 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: List-Subscribe: List-Unsubscribe: As we grow the code, the compiler might make stupid decisions and unnecessarily degrade fork() performance. Let's make sure to always inline functions that operate on a single PTE so the compiler will always optimize out the loop and avoid a function call. This is a preparation for maintining a total mapcount for large folios. Signed-off-by: David Hildenbrand Reviewed-by: Yin Fengwei --- include/linux/rmap.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 9bf9324214fc..9549d78928bb 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -347,8 +347,12 @@ static inline void folio_dup_file_rmap_ptes(struct folio *folio, { __folio_dup_file_rmap(folio, page, nr_pages, RMAP_LEVEL_PTE); } -#define folio_dup_file_rmap_pte(folio, page) \ - folio_dup_file_rmap_ptes(folio, page, 1) + +static __always_inline void folio_dup_file_rmap_pte(struct folio *folio, + struct page *page) +{ + __folio_dup_file_rmap(folio, page, 1, RMAP_LEVEL_PTE); +} /** * folio_dup_file_rmap_pmd - duplicate a PMD mapping of a page range of a folio @@ -448,8 +452,13 @@ static inline int folio_try_dup_anon_rmap_ptes(struct folio *folio, return __folio_try_dup_anon_rmap(folio, page, nr_pages, src_vma, RMAP_LEVEL_PTE); } -#define folio_try_dup_anon_rmap_pte(folio, page, vma) \ - folio_try_dup_anon_rmap_ptes(folio, page, 1, vma) + +static __always_inline int folio_try_dup_anon_rmap_pte(struct folio *folio, + struct page *page, struct vm_area_struct *src_vma) +{ + return __folio_try_dup_anon_rmap(folio, page, 1, src_vma, + RMAP_LEVEL_PTE); +} /** * folio_try_dup_anon_rmap_pmd - try duplicating a PMD mapping of a page range