From patchwork Mon Sep 25 08:28:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13397482 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 E31EBCE7A81 for ; Mon, 25 Sep 2023 08:28:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7ED698D0013; Mon, 25 Sep 2023 04:28:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79CDD8D0001; Mon, 25 Sep 2023 04:28:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 665648D0013; Mon, 25 Sep 2023 04:28:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 54E968D0001 for ; Mon, 25 Sep 2023 04:28:20 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 24034160B2A for ; Mon, 25 Sep 2023 08:28:20 +0000 (UTC) X-FDA: 81274442760.06.A08D000 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf13.hostedemail.com (Postfix) with ESMTP id 5FCCE2000F for ; Mon, 25 Sep 2023 08:28:18 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=A7hHeAJi; spf=pass (imf13.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695630498; a=rsa-sha256; cv=none; b=fAk3iRNUdD4JK3q3FTfYWgrdOou12xVz105OiLcEQiXshNBTqloagqbtQf994n/r38ri9N 5F2O89SGeZBtG17V+etipgw5QZC5VyoKherlTp7UpemHgDZ8RzbM4RoGJCFt/mQkOXqqe3 VzpvbQMYmNZMaCt9E6pwyGPpNXulQwY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=A7hHeAJi; spf=pass (imf13.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695630498; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ny+Jruw5kljLWGVDgFi/c0BN4bXVfRfudV3E3SL5ba0=; b=0iQzVJD+ToavqgnAw80EsJY48/gaQl2d9N4uX8IGwuX2HrSJM0yrFsN27tbipBtjATWDa9 eVnt5j2BAzDl4vciHPZgE/KkPfLpPaOUxnY0XjcYulhCJGPpOfZmn1Qpngw0G5Qvwtuo67 bnU8Y4SnjO8OaH3EGGuXWMgmDpJeCNI= Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-59f6763767dso23979647b3.2 for ; Mon, 25 Sep 2023 01:28:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695630497; x=1696235297; darn=kvack.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=ny+Jruw5kljLWGVDgFi/c0BN4bXVfRfudV3E3SL5ba0=; b=A7hHeAJi2/lqEaWQfNQqLV+BMq5o7jotLND5giA7hVrVMkvLjbm8/v766EFVE6RJCt qDxLJz2L2sgUENjJ7TD6/LlaEqqZaFEJy/7A85AIuzBTqA6jScxRaBSN7ck0WmhZdWL0 bo1+WNoaFJQu1gxFOSbPoSXlR5eVSk+NkunAM5twxJDExRLhYKT7CoFCIksmms2sI07x oNxQZAxbY3yu1yu0oY6f8cdeKEBZHB4Qtg665xQTHPJvBvKTHnP8CfJSEUtDIDJkfFm3 nNUBGX1r/Eroazsp2O98/iqK4WpLF2SQ2D31niZ0iwn8b8BQbsEkMYYhPJ0W4G/UDK7Z 4qzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695630497; x=1696235297; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ny+Jruw5kljLWGVDgFi/c0BN4bXVfRfudV3E3SL5ba0=; b=ks9aOF2qmXtZadNYbaFWQvnk+gzZRJXjGqDrXuXZXVNH605NDbOGRYcAXVOMLjhejP WEqEkmfQrVhYtSOU4x8ltCwJNzvojCiMoS3v3bge69TPk3fPiLo6rLoghlg1k7cKa+tU C1yvMdPVQs8c8xhovoi2TWIZKID/1RuMp/pN1uibrLzLrzUnoVwKWx6Bi8CoMQK0RRKB DzqhmQkjaEZZA+3SZcFj3F9QtIr708ism8P8OkIUsnvlz6Ebpc3nNgduhPaiTPukIHFO vr8JK9FNHPyoxTUc05/jEiQpizwgXkLKNA2stoaFwu2DQtLmagBtIUa0RUXpfD1hKZGl eBAQ== X-Gm-Message-State: AOJu0YxZxj/ErSDTwZ5ycDOz7p7q+oVwG/HOZr4zU2Az62hGkn0bWteH K44K2oye2goUHJQt6d0u+CvXqQ== X-Google-Smtp-Source: AGHT+IH7TByv+2j1g6DH4DUwI+5DujRbEJ2kgtwKlcyesipljkA02KuVspk813qm/mayffaiCSX9vQ== X-Received: by 2002:a0d:f2c7:0:b0:599:b59f:5280 with SMTP id b190-20020a0df2c7000000b00599b59f5280mr5636415ywf.28.1695630497424; Mon, 25 Sep 2023 01:28:17 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id x187-20020a81a0c4000000b0058c55d40765sm2270742ywg.106.2023.09.25.01.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 01:28:16 -0700 (PDT) Date: Mon, 25 Sep 2023 01:28:14 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Andi Kleen , Christoph Lameter , Matthew Wilcox , Mike Kravetz , David Hildenbrand , Suren Baghdasaryan , Yang Shi , Sidhartha Kumar , Vishal Moola , Kefeng Wang , Greg Kroah-Hartman , Tejun Heo , Mel Gorman , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/12] mempolicy trivia: use pgoff_t in shared mempolicy tree In-Reply-To: <2d872cef-7787-a7ca-10e-9d45a64c80b4@google.com> Message-ID: References: <2d872cef-7787-a7ca-10e-9d45a64c80b4@google.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 5FCCE2000F X-Stat-Signature: a5xn6sdbyydh9px4ixsyozktsf1urmxj X-Rspam-User: X-HE-Tag: 1695630498-792172 X-HE-Meta: U2FsdGVkX19HfZLteZQQWpn4TJeDtQ0e5qv/4tMxT+vWpXkHaXK4oq0uePY6ZhK1+jv529x0WgaX0me4WPpe+pchc+fR/vaDEZbAvJmbfyIkliKH4oIehQ7Uuy8J081rgZj1A7F16WqeQR1qs+VrBZiOv5LQvztHKdnhjWCDCcdAdZEpJMXegyh04exdn3+1s1UJwldDmUUZR15Rgd+2t1VT4Xwqm/7m4FF4H6uXtoIx9DQGiK5RjdC+fy8S+eIU3NekiXm5JX3XtOrcq6GUMQj7GzhyNV0vC5a7FHs4ykcRTATwd83RdLY+bbrNMZN6vSVqkO4HQjisZlOgnfQwdK+JbwMXWUlPKOpCJBpWU6MZEU0JvBMiF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pesrV+cxv6EqIHkK1x7q5wn4d02nGcDwttu 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: Prefer the more explicit "pgoff_t" to "unsigned long" when dealing with a shared mempolicy tree. Delete confusing comment about pseudo mm vmas. Signed-off-by: Hugh Dickins --- include/linux/mempolicy.h | 12 +++--------- mm/mempolicy.c | 8 ++++---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 8013d716dc46..12f7dc74a457 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -107,18 +107,12 @@ static inline bool mpol_equal(struct mempolicy *a, struct mempolicy *b) /* * Tree of shared policies for a shared memory region. - * Maintain the policies in a pseudo mm that contains vmas. The vmas - * carry the policy. As a special twist the pseudo mm is indexed in pages, not - * bytes, so that we can work with shared memory segments bigger than - * unsigned long. */ - struct sp_node { struct rb_node nd; - unsigned long start, end; + pgoff_t start, end; struct mempolicy *policy; }; - struct shared_policy { struct rb_root root; rwlock_t lock; @@ -130,7 +124,7 @@ int mpol_set_shared_policy(struct shared_policy *sp, struct vm_area_struct *vma, struct mempolicy *mpol); void mpol_free_shared_policy(struct shared_policy *sp); struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp, - unsigned long idx); + pgoff_t idx); struct mempolicy *get_task_policy(struct task_struct *p); struct mempolicy *__get_vma_policy(struct vm_area_struct *vma, @@ -216,7 +210,7 @@ static inline void mpol_free_shared_policy(struct shared_policy *sp) } static inline struct mempolicy * -mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx) +mpol_shared_policy_lookup(struct shared_policy *sp, pgoff_t idx) { return NULL; } diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 121bb490481b..065e886ec9b6 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2444,7 +2444,7 @@ bool __mpol_equal(struct mempolicy *a, struct mempolicy *b) * reading or for writing */ static struct sp_node * -sp_lookup(struct shared_policy *sp, unsigned long start, unsigned long end) +sp_lookup(struct shared_policy *sp, pgoff_t start, pgoff_t end) { struct rb_node *n = sp->root.rb_node; @@ -2499,7 +2499,7 @@ static void sp_insert(struct shared_policy *sp, struct sp_node *new) /* Find shared policy intersecting idx */ struct mempolicy * -mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx) +mpol_shared_policy_lookup(struct shared_policy *sp, pgoff_t idx) { struct mempolicy *pol = NULL; struct sp_node *sn; @@ -2665,8 +2665,8 @@ static struct sp_node *sp_alloc(unsigned long start, unsigned long end, } /* Replace a policy range. */ -static int shared_policy_replace(struct shared_policy *sp, unsigned long start, - unsigned long end, struct sp_node *new) +static int shared_policy_replace(struct shared_policy *sp, pgoff_t start, + pgoff_t end, struct sp_node *new) { struct sp_node *n; struct sp_node *n_new = NULL;