Received: by 2002:a05:7208:31d3:b0:81:e143:7c29 with SMTP id v19csp2634792rbd; Tue, 9 Apr 2024 12:29:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU487V8aLequVhaP1yTXMAhUebdXR6gY6wiXGyXzCWn4QQlg/2wqqpUn3ZQx3wrfqFoBvC6aPXipDQtRMJx4ta5SusJRaUb/aDR+9WY5g== X-Google-Smtp-Source: AGHT+IHnLv17kit1DKGl7GywFgJxYVuyF8XrWYAjGKnppwM/QTw5NtyWTXHBIj6zqhixOSOFzKGx X-Received: by 2002:a17:906:4c43:b0:a4e:8508:d807 with SMTP id d3-20020a1709064c4300b00a4e8508d807mr273530ejw.0.1712690943158; Tue, 09 Apr 2024 12:29:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712690943; cv=pass; d=google.com; s=arc-20160816; b=Nw+sKnST+D+Ocqsg1VSwcBfJoMoJC5b0BP/mECngjgtjoGg57wezmUmjQo+TBOU8bq U8zyWfiKsnl5f2IUmoV3x6k6Ldt9SxhL37CiXzRo0rC0b7GRMbzzECpBZSlwLcvzH+pU 42E+mu9N5/LC7YzfIcLQKHdMybCziVEk0/p5t2Mn4Oj5luxCEfp1lf/2IHjSikAoEq6/ yy0ztAU3UHq0XtXOZDNfT0xa3cSxrkgJzvfI+mawSYcFnUrkHgUtQO6GlHUT6D1dN1rI LaXHtJG149S9zoFovk2VrCQqCaN8ePI85B+MxJF4SBeiuNKUd89M9ThjmOlIWqKNBZfa wZuA== 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=P0NYc9fiw7RbFbzUOP+c9IZVrablCrwSqa05Gf/mEjM=; fh=6UXOkRl8PLWnLRlJFkZ1FKxRpZrfO06mwvecZ/lFyqY=; b=0XWwHSB3TEQ3+BUaJRawlqbhjz6i4UnAVJva52ObtUdzlWR45lW/6fBSz9nWJlGon1 julevL22lDIXLufqjteVKXjBT1Vwgq2mboapvmRcMCF6qKhgamemor8bLyQx7zF8Ku0N 2S/7lGI150MKAdy5mgG3yA2YB/ewFisMXTrwTKzeGv98XVV6+WaGqZmqXrNHj8kk/Ulh qBlMAy9iUpO/sKg8Yztc8iR5AH7amn5cXkhWUOGkU4GYr/FjledL3l+SVEWL3Jf3R0nh fKuwuH0nj8LNMrB/bPXhjj9z8rnL87hnVPwhaSYeh7K3CYrif6w/QlNCHRIPPloYCMl6 epLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PifanRhK; 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-137532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137532-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i21-20020a170906a29500b00a44444998ebsi5139818ejz.215.2024.04.09.12.29.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 12:29:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PifanRhK; 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-137532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137532-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3AFB31F20FC7 for ; Tue, 9 Apr 2024 19:28:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DEDD1586D0; Tue, 9 Apr 2024 19:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PifanRhK" 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 33F4315749E for ; Tue, 9 Apr 2024 19:26:22 +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=1712690783; cv=none; b=c6gdEb+K9dlQFiLZS/i0DnY0S6BocGztuTmYlDtqFRG4bWkHMdiAYiiv1tSv01xkNJ9QGIjPgqIzhkSwOjikoKgRqLfZ2ZoIlUB1k0c3EnFCAKXZxT32jPy/CWo1cTuFv+puXxbnvnTYtKeHU3TDdM/nWhfV5X5AhfZ8OpLrXkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712690783; c=relaxed/simple; bh=67HUJ37QTSZsMQ5QZmRvA1nLGckTDZres9pW7a3nEco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zq8XtZqTx47ko/en8H7X9vAuewgr/w8+wz8sKahiE2pEMiJtXqp7m5w6tNoXeyGWytM31bKOfcYGBmBgwZ8Qm6y/WPKNO9Wgwjp66WV+XtF4ZD95v9LmjLo/wJxelaQqY5liWIQIaG4aMFUVZBZv86C/zx1X1PLHG/m5J6qG1Mc= 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=PifanRhK; 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=1712690781; 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=P0NYc9fiw7RbFbzUOP+c9IZVrablCrwSqa05Gf/mEjM=; b=PifanRhKtHC+q6DszmwWXFttV97v5KhkTV3r2fI5cE1bRgpmNae5jnjfW/wHKQpPVSY8R5 TwYAbl6uffl9hQjoXa88gEt8mp7ip92TJ5em/WWi4RIpx7sRy14eV8T3Wg8+dQSablh+QT ZZCZrADcXiY+GotAcoIuPBCo7EAg888= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-227-LSK2VHheNtull5pEDNikGw-1; Tue, 09 Apr 2024 15:26:18 -0400 X-MC-Unique: LSK2VHheNtull5pEDNikGw-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 EBA28890521; Tue, 9 Apr 2024 19:26:16 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9815E40B4979; Tue, 9 Apr 2024 19:26:08 +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 14/18] mm/migrate_device: use folio_mapcount() in migrate_vma_check_page() Date: Tue, 9 Apr 2024 21:22:57 +0200 Message-ID: <20240409192301.907377-15-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 We want to limit the use of page_mapcount() to the places where it is absolutely necessary. Let's convert migrate_vma_check_page() to work on a folio internally so we can remove the page_mapcount() usage. Note that we reject any large folios. There is a lot more folio conversion to be had, but that has to wait for another day. No functional change intended. Signed-off-by: David Hildenbrand --- mm/migrate_device.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index d40b46ae9d65..b929b450b77c 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -324,6 +324,8 @@ static void migrate_vma_collect(struct migrate_vma *migrate) */ static bool migrate_vma_check_page(struct page *page, struct page *fault_page) { + struct folio *folio = page_folio(page); + /* * One extra ref because caller holds an extra reference, either from * isolate_lru_page() for a regular page, or migrate_vma_collect() for @@ -336,18 +338,18 @@ static bool migrate_vma_check_page(struct page *page, struct page *fault_page) * check them than regular pages, because they can be mapped with a pmd * or with a pte (split pte mapping). */ - if (PageCompound(page)) + if (folio_test_large(folio)) return false; /* Page from ZONE_DEVICE have one extra reference */ - if (is_zone_device_page(page)) + if (folio_is_zone_device(folio)) extra++; /* For file back page */ - if (page_mapping(page)) - extra += 1 + page_has_private(page); + if (folio_mapping(folio)) + extra += 1 + folio_has_private(folio); - if ((page_count(page) - extra) > page_mapcount(page)) + if ((folio_ref_count(folio) - extra) > folio_mapcount(folio)) return false; return true; -- 2.44.0