From patchwork Tue Oct 3 09:21:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13407336 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 7A79DE7543A for ; Tue, 3 Oct 2023 09:21:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B3936B015D; Tue, 3 Oct 2023 05:21:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 164986B015E; Tue, 3 Oct 2023 05:21:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02C8D6B015F; Tue, 3 Oct 2023 05:21:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E87D96B015D for ; Tue, 3 Oct 2023 05:21:39 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C3972B3B51 for ; Tue, 3 Oct 2023 09:21:39 +0000 (UTC) X-FDA: 81303607518.27.6AC2E19 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf03.hostedemail.com (Postfix) with ESMTP id 0C11D20010 for ; Tue, 3 Oct 2023 09:21:37 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=FallctNc; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.222.178 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=1696324898; 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=TKEb9Cd3xCSrgbL40B7c6RQSPbdbractxdPzCveSCj4=; b=u1RWTA/kisgrItYu5I9W8dq2UXN3/YwdHwTGG+FYQsOEFHffMcF0A324dn1mnuVtVcLcu+ ZeKnuvoVrSdA1hskiDOpaNWRz8TMN8eURokHtyL+cYFaRheXW1Lo1yJnUbRYC39JniN52L W2KfJxsTh3j1QB+LNm2vLzN7bMoGDG4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=FallctNc; spf=pass (imf03.hostedemail.com: domain of hughd@google.com designates 209.85.222.178 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=1696324898; a=rsa-sha256; cv=none; b=cmaR6f5S4qHyY7fPyCSE4E4eF6rDttvZIozB0fH6XWmC1g5tm0gWehZrvG76Tofc8RCx7a TNfC2Saunrd2PTc084kx4X//7F9b2htjjm5g66Dse4Pd2o/lcjdKn+gE3ZeD4dtcxkrReX XC1OL/JHZyDXIb0VQH3Y9QbpXhiCJXo= Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-77433e7a876so54160285a.3 for ; Tue, 03 Oct 2023 02:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696324897; x=1696929697; 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=TKEb9Cd3xCSrgbL40B7c6RQSPbdbractxdPzCveSCj4=; b=FallctNcGWoeABOLkfUG1a3SDZzm2y6slUClTFndE1ABJigRmJE/f2+QNitwhQkvU2 Jx0x5QsYTK48NEUIlmQWynDQHFlVAeoqiTq51Yy7ncMWnrRtUna6Xng1Us9ZRP8kzRG9 DIriomX8CHowCty9/yPxyGqeC7+i7fIrORIuvo8qC0ybdikcaRO+4EW3s21NWF1jyxx9 KqraOKOaBxov0+y68QH3hFwoWsDQfQo7d5rI8Rsvf7G1pZXsKRDrFOtag81yGNxQSvyg InpqBFY9R7VuEAGf9Hv1OL1yyF3DQAhjzcjs3qGI0noYsamuz2MVBEhetAaRztHWaHNn I6cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696324897; x=1696929697; 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=TKEb9Cd3xCSrgbL40B7c6RQSPbdbractxdPzCveSCj4=; b=meyRbaI/6pQuxCksLR0O+dH8h+uV7zycxce0RDn2Z5ehkE80PBe9zxL7wCDIKJYe2X weLI6dSxLtm8icXJWLP7cOxaCIXWQKy6V36f620mtRIJZ3Ir8/4HOtksgWBBt/FQ5Pn2 qJjixzxCEZpK8/EUl75hyfoohQBZ5fCaM/w6GHe6a/oQgTwn9ZfcdFR8fzk/OHejbTSC eoisAT06M9hE/DwKT4b/3lEaub24A9tvxFCMSY8T91jk6PR985xOl1iF3klNeOv6ibUm hUqS3ajioOrnjtlssJfM7eKe4Ab2PtQZh4N01Vs8ZsMlxqHWF4PuvOM/iz1B0RrbUHaR qNOw== X-Gm-Message-State: AOJu0YzwRoUAPnRtYls48Ts0uFxNwpElfAtOZuODpohwRPbGyJHqrqRB j2FojI4buxVLOd1s6LKrk7OkLg== X-Google-Smtp-Source: AGHT+IGmyNX1mGOvsxjDJ+VgdVzrziqLJLl2hhCUT+uZ6s1yuT2hqDhi9cPwKTZ3QGcrdlo0VxUawQ== X-Received: by 2002:a05:620a:95c:b0:774:1d91:e41a with SMTP id w28-20020a05620a095c00b007741d91e41amr13254046qkw.77.1696324897011; Tue, 03 Oct 2023 02:21:37 -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 a14-20020a81bb4e000000b0059be6a5fcffsm247867ywl.44.2023.10.03.02.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 02:21:36 -0700 (PDT) Date: Tue, 3 Oct 2023 02:21:34 -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 , "Huang, Ying" , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 06/12] mempolicy trivia: use pgoff_t in shared mempolicy tree In-Reply-To: Message-ID: <5451157-3818-4af5-fd2c-5d26a5d1dc53@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 0C11D20010 X-Rspam-User: X-Stat-Signature: dyzzgse3t1tcqdwjw57d6anp1ni74nm3 X-Rspamd-Server: rspam01 X-HE-Tag: 1696324897-605627 X-HE-Meta: U2FsdGVkX18COa8sOkA0HRUnazJplAObt6QJdkHAdvri3PRVRSA6I6yl37dn8hSMIe7HS6bfPVU6Vzkp0wa4d71grTdbARcvAmSv2UoAXX7txX9PSa2/MYG+N2Ll3TQoCOWQD+xdgia11clsv0S2Msm4P1aGFo/OXWjjf/4rbHqqiLX1WaF8/1eGYJjcYmLWJsQFNW1lrJH2Ih3VJMBPLQOW73ZUQlFHX06Og/6S47G+Jc5P23c9Xm/zBbRuvgNT8m8Iiuy+RuElK/bqzINIi6WwVWaMGEu3dxhnL6qmMaXFR1GCGPYp63kpkfJIoQlB32A0kuLEAkOjlgjp4UKG4btFZ4cH6G4NXrFOSkLVwPCKW0NPjgR46SbS7CvGYNIj4/jMMc4WP697cXKVw0Ic38txw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PyVK9Uri0D2Fexxueq 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 | 20 +++++++------------- mm/mempolicy.c | 12 ++++++------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 325b7200c311..c69f9480d5e4 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -107,22 +107,16 @@ 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; - struct mempolicy *policy; -}; - struct shared_policy { struct rb_root root; rwlock_t lock; }; +struct sp_node { + struct rb_node nd; + pgoff_t start, end; + struct mempolicy *policy; +}; int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst); void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol); @@ -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 c7906a034959..1d3f9e1ecbb8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2448,8 +2448,8 @@ bool __mpol_equal(struct mempolicy *a, struct mempolicy *b) * lookup first element intersecting start-end. Caller holds sp->lock for * reading or for writing */ -static struct sp_node * -sp_lookup(struct shared_policy *sp, unsigned long start, unsigned long end) +static struct sp_node *sp_lookup(struct shared_policy *sp, + pgoff_t start, pgoff_t end) { struct rb_node *n = sp->root.rb_node; @@ -2503,8 +2503,8 @@ 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) +struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp, + pgoff_t idx) { struct mempolicy *pol = NULL; struct sp_node *sn; @@ -2672,8 +2672,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;