From patchwork Mon Feb 26 14:13:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 206673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2105501dyb; Mon, 26 Feb 2024 06:18:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXs+DhwN+rFAskyW4pUQC1Emc71hLoyJ8mJm2vfXLP5+ztsyrfTPGNSAGWiMKmyT4gaDABq8J6q4qqsWfZJZT3Z20zyvQ== X-Google-Smtp-Source: AGHT+IGWKrjp67TZyjMtmaZc/1u/i/gZ/10sFxJK81Bm4Y9Veyp7psL63fXSNCT7AoYgQY4x2dQ0 X-Received: by 2002:a17:90a:3fc7:b0:299:8e70:e9a5 with SMTP id u7-20020a17090a3fc700b002998e70e9a5mr5613462pjm.20.1708957089658; Mon, 26 Feb 2024 06:18:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708957089; cv=pass; d=google.com; s=arc-20160816; b=YJ7uxL86AGJNddkVNLzLdyCash6VbO6N4j59GPGFz+xPycvS2ATfq51qVDCv5HVnd8 IDgA5Rhj3E4Z2u7BZMRsBjbXXcqYF8OSlPi8+uZ1uU+HOX6KThKskwakiR8Z6tqkhWMe hRKaFN+1KHdPV8xB4+1aRGMCqY3mhmRyPY8r+vr4XEkuLi2RgYHZO2uheiXLNk/NBTdX nwszOUNsiFiG2hMAVp49manMMsZRQERDAHUz97WTlzSNgmFdgwuPveFt28Ttp8bQP7VX cLDqqJdxCcDbNd/kNHBYyPHXOz++j4bhRdxafkSm71iHrcUcF5fhDOY9rH7gJxCzfYax rpyg== 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=2GkNOw5QpbIjcnEa8hertH5KYBOVS1V90XYQHHukH+0=; fh=wm/PuDf5kO+3RFpgEWpn6tkOmws9Iy+MHxtReSjFHG4=; b=pD2J58r4Qo0d6NT5V2Nt4DNRRgoSSyUaORKLe8LTEinjpfolXUpld/dRCQzNHjhmvX XwXhzax91SjEzN1Rf6mgFStYpHoJ9pTs+tXmFXIkxCHHqxZnz3S9pzsOhnjoOzFCqVRr qsWzNXuXEUVgX3NAO/UqFbQ5JTcYp5L3T08Xpsqj82cB7veZjeu5I7r/WZxMe5C6mTn4 NOMRVJWeixNqOyH3ceDIcq0KYD7QLWrQx+/YIbMntcGV04bpd/13zVipIB6EAYnjNWHN +qXfmiOTcwUWJNfgtUR5LSFMUh/Et/BEkOJvlecm+gwpAvb1SifL8DvoS+jYn38ffhgZ O3Mw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FO+OY0YE; 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-81596-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81596-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bo23-20020a17090b091700b0029a858c0e28si5054649pjb.36.2024.02.26.06.18.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 06:18:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81596-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FO+OY0YE; 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-81596-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81596-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D19F129249C for ; Mon, 26 Feb 2024 14:14:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A3D23129A9C; Mon, 26 Feb 2024 14:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FO+OY0YE" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 9DC631C6B9 for ; Mon, 26 Feb 2024 14:14:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956852; cv=none; b=mEG09yHx1xglaHOWEjmImmPc4ROU45K7Y2nmFpApqT+GWhfspBjfj6LVh0qi6ns9eXJF+dF+XC/gzXExCnwsS5I+D/9i3vpAjwdLE5gZL23Hu9Ni0pS6hAC6qhmms0CAeXfIC3oClA067QWhSe3tBXFbzKaofIx+h+4U1uGHASo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956852; c=relaxed/simple; bh=LlRCRH3uYk/2lkWlcthuzE6Y+YWYxlmcDmZGNRkMNp8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbOZUi1MRczeZQB1GtfDpB4snitpZkj7+CgbW3ePrfG++XiSmhxyv5aLHrZpDIs8RcT8y6B9gauDvB1vNLWID5Xo0SzPLQLZyKWO+gs4LnqtyZGaAp0Zb28/hn2nwaTiueGnXVUfevXN4QKonZYHTknNF1jsj9INfSnBQfKV7sY= 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=FO+OY0YE; arc=none smtp.client-ip=170.10.129.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=1708956847; 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=2GkNOw5QpbIjcnEa8hertH5KYBOVS1V90XYQHHukH+0=; b=FO+OY0YE7/v3F5zmkawZ6ewR4/zGn5c9ZeHumWIwOT+Dgm4i6giVU/j1h0Wf7harz09U1D wMlS5ejG8mIc/UhQTgwtNaG/xyloXvzywIWs01cvwccynn1i0w5tqQU0gVzHEvkGZTQjA/ NUGTvFgfgGBa5n3V36dIEE5vNKVv/Ec= 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-53-xi-W6UmKPPiav4O4IAf97Q-1; Mon, 26 Feb 2024 09:13:38 -0500 X-MC-Unique: xi-W6UmKPPiav4O4IAf97Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 8E6403C025C0; Mon, 26 Feb 2024 14:13:29 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 072AD1C060B1; Mon, 26 Feb 2024 14:13:27 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox Subject: [PATCH v2 1/2] mm/memfd: refactor memfd_tag_pins() and memfd_wait_for_pins() Date: Mon, 26 Feb 2024 15:13:23 +0100 Message-ID: <20240226141324.278526-2-david@redhat.com> In-Reply-To: <20240226141324.278526-1-david@redhat.com> References: <20240226141324.278526-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791971389155245256 X-GMAIL-MSGID: 1791971389155245256 Both functions are the remaining users of total_mapcount(). Let's get rid of the calls by converting the code to folios. As it turns out, the code is unnecessarily complicated, especially: 1) We can query the number of pagecache references for a folio simply via folio_nr_pages(). This will handle other folio sizes in the future correctly. 2) The xas_set(xas, page->index + cache_count) call to increment the iterator for large folios is not required. Remove it. Further, simplify the XA_CHECK_SCHED check, counting each entry exactly once. Memfd pages can be swapped out when using shmem; leave xa_is_value() checks in place. Co-developed-by: Matthew Wilcox (Oracle) Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: David Hildenbrand Reviewed-by: Matthew Wilcox (Oracle) --- mm/memfd.c | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/mm/memfd.c b/mm/memfd.c index d3a1ba4208c90..7d8d3ab3fa378 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -29,29 +29,25 @@ #define MEMFD_TAG_PINNED PAGECACHE_TAG_TOWRITE #define LAST_SCAN 4 /* about 150ms max */ +static bool memfd_folio_has_extra_refs(struct folio *folio) +{ + return folio_ref_count(folio) - folio_mapcount(folio) != + folio_nr_pages(folio); +} + static void memfd_tag_pins(struct xa_state *xas) { - struct page *page; + struct folio *folio; int latency = 0; - int cache_count; lru_add_drain(); xas_lock_irq(xas); - xas_for_each(xas, page, ULONG_MAX) { - cache_count = 1; - if (!xa_is_value(page) && - PageTransHuge(page) && !PageHuge(page)) - cache_count = HPAGE_PMD_NR; - - if (!xa_is_value(page) && - page_count(page) - total_mapcount(page) != cache_count) + xas_for_each(xas, folio, ULONG_MAX) { + if (!xa_is_value(folio) && memfd_folio_has_extra_refs(folio)) xas_set_mark(xas, MEMFD_TAG_PINNED); - if (cache_count != 1) - xas_set(xas, page->index + cache_count); - latency += cache_count; - if (latency < XA_CHECK_SCHED) + if (++latency < XA_CHECK_SCHED) continue; latency = 0; @@ -66,16 +62,16 @@ static void memfd_tag_pins(struct xa_state *xas) /* * Setting SEAL_WRITE requires us to verify there's no pending writer. However, * via get_user_pages(), drivers might have some pending I/O without any active - * user-space mappings (eg., direct-IO, AIO). Therefore, we look at all pages + * user-space mappings (eg., direct-IO, AIO). Therefore, we look at all folios * and see whether it has an elevated ref-count. If so, we tag them and wait for * them to be dropped. * The caller must guarantee that no new user will acquire writable references - * to those pages to avoid races. + * to those folios to avoid races. */ static int memfd_wait_for_pins(struct address_space *mapping) { XA_STATE(xas, &mapping->i_pages, 0); - struct page *page; + struct folio *folio; int error, scan; memfd_tag_pins(&xas); @@ -83,7 +79,6 @@ static int memfd_wait_for_pins(struct address_space *mapping) error = 0; for (scan = 0; scan <= LAST_SCAN; scan++) { int latency = 0; - int cache_count; if (!xas_marked(&xas, MEMFD_TAG_PINNED)) break; @@ -95,20 +90,15 @@ static int memfd_wait_for_pins(struct address_space *mapping) xas_set(&xas, 0); xas_lock_irq(&xas); - xas_for_each_marked(&xas, page, ULONG_MAX, MEMFD_TAG_PINNED) { + xas_for_each_marked(&xas, folio, ULONG_MAX, MEMFD_TAG_PINNED) { bool clear = true; - cache_count = 1; - if (!xa_is_value(page) && - PageTransHuge(page) && !PageHuge(page)) - cache_count = HPAGE_PMD_NR; - - if (!xa_is_value(page) && cache_count != - page_count(page) - total_mapcount(page)) { + if (!xa_is_value(folio) && + memfd_folio_has_extra_refs(folio)) { /* * On the last scan, we clean up all those tags * we inserted; but make a note that we still - * found pages pinned. + * found folios pinned. */ if (scan == LAST_SCAN) error = -EBUSY; @@ -118,8 +108,7 @@ static int memfd_wait_for_pins(struct address_space *mapping) if (clear) xas_clear_mark(&xas, MEMFD_TAG_PINNED); - latency += cache_count; - if (latency < XA_CHECK_SCHED) + if (++latency < XA_CHECK_SCHED) continue; latency = 0; From patchwork Mon Feb 26 14:13:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 206672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2105394dyb; Mon, 26 Feb 2024 06:17:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVaNDINNuIpa/HAODQMbh7D2qU4YuFNf91OhlU/k8oIq0z9Ef7+/o97qCu/rmhEDnTL8S9WzTA64oldnW1dxyUBm0aUpQ== X-Google-Smtp-Source: AGHT+IEKLZf4ma2u3ERxXG3xh2hcDnbXCpF8MC9Rl81RYU+C2EBZ0x3bCPHNydF/R/p00Le4jFga X-Received: by 2002:a17:902:db01:b0:1dc:6373:3cc with SMTP id m1-20020a170902db0100b001dc637303ccmr7274256plx.50.1708957079774; Mon, 26 Feb 2024 06:17:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708957079; cv=pass; d=google.com; s=arc-20160816; b=Z110Vljtby2YQuUYtPJmTUgtw5vlqZiPEEC65pTRE/jdZxMLuc/eMYoKxZ3gKrZ/75 Db1nXUiR/8onTuaOO7t1Htmca5AQW+WTiNCrBilj8SfdNpHZGTavFtIjUcEd6Uyze6qW qtkSWkFks6mZQkpBaHX6N1JGv5DIwkySSzUe2JxafbK4CsBI085RXsHwDHWSRWVn9Eig nA2F3czCOZxQBkcnJnlt7kgrzzXpaI04bbBmoWh3+eBdxH06OPoPJ3BmmpchTvUVuyRV NxL/Xct3pMQb4gVX5Zpq2Q6cfkUSECh2CQFRcpVnG+wF6J6FgLGXFMgNjT0xk+VHp1wk w9+w== 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=fzz4oIdsJNeqF+PoyUnhajnBU3sMK99bnWW/MxMH7Ys=; fh=wm/PuDf5kO+3RFpgEWpn6tkOmws9Iy+MHxtReSjFHG4=; b=cySw8K3mdlB2dl2mjfJcYeWr8NP9cc0y4DmYad4/wSNptMdhp3T31shYd55YR68GwZ Ar3E9Fjmw7g0UkXmrFnQHn69Ka10qaCbDCYhqPqsriwXD8JcqufXX7Kr4spV6NqhMk7B lwsxaR77p4778mXzCk5DR6P3d9IDEINKgwmYVPXsoc6Ozp82dgusGBhk9z0+JQriE4kZ SqPVAMnJLbtNw9/Ri4LEu+EkuOR5BsaY3AU70HU4AQ5nlwVnszWc0VTj2CkZIREyYHCt NrwlsSvmjziYeAL4oi/cyRnuyuhXzaQ5L8dk8GycPDFGq2aXdEuWxDBO5G76w1KmgHJo VX6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UOgXB6WA; 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-81595-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81595-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l18-20020a170902d35200b001db7c5ef0a6si3727098plk.136.2024.02.26.06.17.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 06:17:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81595-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UOgXB6WA; 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-81595-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81595-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4A77F292349 for ; Mon, 26 Feb 2024 14:14:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C966912B151; Mon, 26 Feb 2024 14:13:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UOgXB6WA" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 CB45E12AADD for ; Mon, 26 Feb 2024 14:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956821; cv=none; b=Z+dRmyULmdvqx0pktkhhUweIN06Jo7MsO6gTQDWkgjlo8n3jsMI6XHgXNL2ZY9/gV2PZ85ouJKnqeZiZKUiztbA4/XKsXT7CS1PPanpGw65YCQIIwQur0rXKZAfD5BHHC/OH98DV84eXO6bj0Gaekxz/ZfyMroS1TMDoJt2qZt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708956821; c=relaxed/simple; bh=GWrvOCNTQBiOgQYlCK+1fhIT/QiAP3OOhXVDcNrF+mM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zlf23dnJH/pN934tCdFjZSX3aBJ70aaHw3gZcZ3tjt8EQXeuQ1htTAM4lODo7RVuM8ODWiO5dNbGE+S3gO80h/TzT+/Dgk5idPZATpmF88DU/KRGU/m/ek7EX2yR4epexHfyJCdiAMN5iyrUSyua9lf7seNpOHYjrxarDtD/oYs= 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=UOgXB6WA; arc=none smtp.client-ip=170.10.129.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=1708956817; 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=fzz4oIdsJNeqF+PoyUnhajnBU3sMK99bnWW/MxMH7Ys=; b=UOgXB6WAZ5Ub1kroDzD+Ic5+8MtBQ6RF6asrspqHxU3NqGsJRFaPScxdL/0W0+qseU5EEO DhvjJjC8myyzfmMhVqjt3IFIjZzsJVzVdZP13CTo1YqnaGLt2Pp0N0nj+8ml12dvr6KTyP t31s+S+IQHI8MneXsXWLShmsL7BBHMs= 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-531-a1B9APTNPEOyuSsYVlQSgg-1; Mon, 26 Feb 2024 09:13:32 -0500 X-MC-Unique: a1B9APTNPEOyuSsYVlQSgg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 864803C28642; Mon, 26 Feb 2024 14:13:32 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEC821C06710; Mon, 26 Feb 2024 14:13:29 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox Subject: [PATCH v2 2/2] mm: remove total_mapcount() Date: Mon, 26 Feb 2024 15:13:24 +0100 Message-ID: <20240226141324.278526-3-david@redhat.com> In-Reply-To: <20240226141324.278526-1-david@redhat.com> References: <20240226141324.278526-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791971379038971718 X-GMAIL-MSGID: 1791971379038971718 All users of total_mapcount() are gone, let's remove it. Signed-off-by: David Hildenbrand Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6f4825d829656..49e22a2f6cccc 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1183,7 +1183,7 @@ static inline int is_vmalloc_or_module_addr(const void *x) * How many times the entire folio is mapped as a single unit (eg by a * PMD or PUD entry). This is probably not what you want, except for * debugging purposes - it does not include PTE-mapped sub-pages; look - * at folio_mapcount() or page_mapcount() or total_mapcount() instead. + * at folio_mapcount() or page_mapcount() instead. */ static inline int folio_entire_mapcount(struct folio *folio) { @@ -1243,13 +1243,6 @@ static inline int folio_mapcount(struct folio *folio) return folio_total_mapcount(folio); } -static inline int total_mapcount(struct page *page) -{ - if (likely(!PageCompound(page))) - return atomic_read(&page->_mapcount) + 1; - return folio_total_mapcount(page_folio(page)); -} - static inline bool folio_large_is_mapped(struct folio *folio) { /*