From nobody Fri Feb 13 14:10:11 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0A2ACE7A89 for ; Mon, 25 Sep 2023 08:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232795AbjIYI20 (ORCPT ); Mon, 25 Sep 2023 04:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbjIYI2Y (ORCPT ); Mon, 25 Sep 2023 04:28:24 -0400 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59CA9D3 for ; Mon, 25 Sep 2023 01:28:18 -0700 (PDT) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-59c215f2f4aso73611007b3.1 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=vger.kernel.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=YJehBPjLRrzsJRRRxYwf5k2fr3z5ZmoQcsUDS7Yt/XX6Q5ZsOznEI/tgaNd1g3+X0r RUllEWlxZlWzYbS/SqaaCAP/7qpaV11Kc65h9obAOZqv/mtmVXQ6FbEMRs2gctaucrLA C11XFIPvhAUpqJ4ad3s17FV1mZSc2nGKYIVVdn4/WHmqRWTcE6+k308S3dlTQDmPf8HV LLzJqT21h6vZnwmBpyIvG2wTIppvcdXQIXav6xAcxd4oEZ8Hh60UAQg8mBWrIVmFGgBG Fl1SGnSEUvnJWHtY0mT07kZyF7xb85p9/JAGNT+o1144rjy9VA/DsI43fOL+AxC03Mxy eqPA== 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=Wv6snQhmxruoKABYf4NilPhirw7I300GbUpv8BtuvLvAmtiR5a0RIY6mCmu27jS0J3 tgOO0h2oxMSbHil5KHuLrj6R1/DmxpsOKWMkqPikWzwnCC0mk7pNo16tzpPzFvH/svXL tdZWionY5zyfuqGP/1avyso35+lAV1RvbUb6nOi0IbNry3qdaLaBP+48CNRxau3gdDau 5bgKJ5Q+H351r0tbRtm2TZM06IxtzNQQgRc928tsdu+XYuxz4BgPTsRUblnQOUy0Yh+w r80zYEIgw/svH2hIE6jdwrDS/+KQBSVu9UCCeqSpEszu3BqQRvPU7C52mI8wU/xeNFA6 8LAQ== X-Gm-Message-State: AOJu0Yy7/mopuarUWw3oMlmrWC4s/DUKue1r80D1dc5gJwlHZnA5dFvC 7NlEgwW2Yb1JtfY0DsPIUM0TOw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, st= ruct mempolicy *b) =20 /* * 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); =20 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 share= d_policy *sp) } =20 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 mempoli= cy *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 =3D sp->root.rb_node; =20 @@ -2499,7 +2499,7 @@ static void sp_insert(struct shared_policy *sp, struc= t sp_node *new) =20 /* 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 =3D NULL; struct sp_node *sn; @@ -2665,8 +2665,8 @@ static struct sp_node *sp_alloc(unsigned long start, = unsigned long end, } =20 /* Replace a policy range. */ -static int shared_policy_replace(struct shared_policy *sp, unsigned long s= tart, - 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 =3D NULL; --=20 2.35.3