Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp2633459rbd; Tue, 9 Apr 2024 12:25:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqzVUWVBLnHsRCiQwAaOr/O9De7EOrjeQvET/zSs2/5Xz8E9G0dFsmYa+tHwfuaLkgw2yPHBDe5XW0Ux1uz0bYPLexZMVw/evWRAdqEQ== X-Google-Smtp-Source: AGHT+IH1gSNzFhhNoUnFzjmmxqBalOXEVCvX8rE0nt1RvcIRaFebs5eJHSLEC8MM0cd8uIm6TOfw X-Received: by 2002:a05:6870:f20e:b0:22d:f83c:fb3a with SMTP id t14-20020a056870f20e00b0022df83cfb3amr622290oao.9.1712690738437; Tue, 09 Apr 2024 12:25:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712690738; cv=pass; d=google.com; s=arc-20160816; b=UmvOhUyIL9VP6+9TJOqsWZdhkUh6sKAMWobDvYhZMLCxcJBNTkrajgLKoKy6D+JHji vtksL8oc64UqjrCsGsbTkayTaddtQ6oFW0BZ+JGHMAUrd1wwP+07yet68p65ITEbPDWl 1IpIp5vPFJcADFI/wMB+jkhk4ZDHPcMb60r8L3VlXPWqxy50ovRHjlPWcZgHzfpixBBT o7A1svrDGkjxalDnIifNtlAjRBG7Mgf5m/2JxgA45vy0kW8MK26MkumEajcSmBdSkctA 6KyAACW9NrspDUFQNa00djj9waOoiU8ceNjjzz3TGxbEE51aE1arhxmUuZho92rCS6mN eaYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=omUW48lRIosbAMPj8czTvBZpGDzoyoLuJmkkL5iPx/s=; fh=6UXOkRl8PLWnLRlJFkZ1FKxRpZrfO06mwvecZ/lFyqY=; b=eUXwWrgjEblR7PxJeNDHihWXpDFt3Qsl8ZYHXfcxRFJpWgIInxnSztQiCVZYPZo9dw TT51YzkdqVeN5sYflMKJkrc6DHiuKtjkMWFQsyyRtGwR2s6wMx/hW75riNw1ZaVBu1Ll 3QKQaO61v61y/diihjoWNH/pQo23p5BnwWHL/eaXywWFCuo5aEHa+ppfYecpm2RZylSu Hhod7AKyU52SG5gNP3KC42/azHr9gM3QHoZVkGfrxgJtF8orvBP8G1LPBBlQ11s5bIFO NIgvtaP9Pu++/svEkFtkrEAliqLrwWQ2TI4SWPgZVj4/GTZHwpEuYVs/z6N6hydubcRd L7Ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HbQ8J0GV; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-137517-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s198-20020a632ccf000000b005f07f35ac2fsi9032212pgs.722.2024.04.09.12.25.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137517-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HbQ8J0GV; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-137517-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 56971B23594 for ; Tue, 9 Apr 2024 19:24:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D0C9157A42; Tue, 9 Apr 2024 19:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HbQ8J0GV" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49BFB156F5D for ; Tue, 9 Apr 2024 19:24:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690647; cv=none; b=WXKTDCkemnrvBsQ4pLFRp2uj7sF9/XJ19JBy9UiqFtWxX9JN8QIVnvGk6W58mtWnMQ/FgJwqeSsGCIZESXcVOHfGDbr9ccQV27jzaVaQem777Py94f5fkLiEtJP1lkGpb2itgcudenl5QROzx5lVzwbb12dSTCjKi5habaRlEFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690647; c=relaxed/simple; bh=C6vsGAS9Kt2C12HcsVEZN58MdmMVsleriWzOb3OfiVs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CFclAD3qeo65SxwtJqymB+Jzd+DnMQYKuBKN0jnsNDnZi9nfEXxst/kV/vLD8H0lOQ7/xhO2zT3VWvTQbAnX84gANPk6D9oa3OpumvCIUN2npBXC3LLELc1zQmwzOI6LS9qCEFgZWm8sMx0YKjLjIscXkH4AxiQps+BMXqwSv7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HbQ8J0GV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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 --- 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 -- 2.44.0