Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3170777rwl; Thu, 13 Apr 2023 17:13:05 -0700 (PDT) X-Google-Smtp-Source: AKy350ZhVW8dQLwqREFveNGDwQTwke5FHnD9m7LqjddZqVbB7EnkUNE02KL1c+ATqkuFafOyy9qM X-Received: by 2002:a05:6a20:144c:b0:ec:6882:f04b with SMTP id a12-20020a056a20144c00b000ec6882f04bmr4167166pzi.8.1681431184823; Thu, 13 Apr 2023 17:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681431184; cv=none; d=google.com; s=arc-20160816; b=r98W3MpFcI/7YAkYCMKLxKXSil/EWa8ieJ6ixU+GZbA/rnA4xiDm49HSVzdAjmlcmG wCf11F22t9I12STh8owyUPFaWYunvpIqBC2X8gteOIK9eotzEdc3RNip/MKdFfutOMNm gVrEYADWx23jA7k1wRDn8vQUL5VC/pulaJhOAnIXvf4wlF9HQbODGd1sMOUE3Ot1QZeT /3TFB65LAFW+dSUsCtsM+LmMt5r6xTvFaUSi2UX+ignyZw5QzIR7yN1LstVmcARDLKVY y+VQKJqbZ8e1+X108EDgxDbroarI1LXf0JpKeHnTmcdKOS5Gcle9FIEgx6WuAVpqGteh 800w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=LGz+M9nFtzHbGGbLaqDB42+XLCRk5tnoOBaeHE6w0dg=; b=FeyBiVMj9ijs4zPNXBUY97OgTY1fbgpgK6AnseSvpUHBk1wYkT3YOz3rT2RI8dqElf a1oxwR8aZJ4t0tqK2Ag2CarDW6tfNBr0Vz07Dh8hvegyGTFXA38/3euC9lbgh/N7BAt1 J0nlID7riQIjG1Du3KQifc3hWT8tYzoai7gi7BjLZIq7KQ2LnUNo4cle8l+C/G2aCbYA kw/C/V8dRh9wVYUugHXBxQVrqJlngPBcXeZ8M15nFjXFsf0lrIK8zfOPznFs3PNmyFL2 Sws7L+fFIW9Mzxhok1rLON6+V+euFlaHDO+NcD+mAh26iYnFvS+m+0Dj0maW64iIXX5x 83/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=S5LluL5N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 65-20020a621944000000b00638b8a3807fsi2814964pfz.295.2023.04.13.17.12.53; Thu, 13 Apr 2023 17:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=S5LluL5N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbjDNAMG (ORCPT + 99 others); Thu, 13 Apr 2023 20:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230117AbjDNAMC (ORCPT ); Thu, 13 Apr 2023 20:12:02 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6AFE3C21 for ; Thu, 13 Apr 2023 17:12:00 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id z9-20020a170903018900b001a1e8390831so8701543plg.5 for ; Thu, 13 Apr 2023 17:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681431120; x=1684023120; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LGz+M9nFtzHbGGbLaqDB42+XLCRk5tnoOBaeHE6w0dg=; b=S5LluL5NFzRfMffvrC48pA8vM9jBztEWtYOdVu6RC2ufBdtUUSqD+XyBpvK1yq+IN2 IHnZhiT1W0yssxQ4r7Y9clMkV6zvB2ogiOPODlbRwrRyDr07/qDDpZBBDVLk/N65uZzy CN1ozoAyt0GCn/Q/UB/ZvGZUO3F2PMmedv6i9jH6jJ0uY0cAH01PJa7G0h1cPoPbYq3f IdXBPJH4a6Ro/C6Sct1ltwBhbcLCAMsdz4Y30Y2jgpBNq+x1h2YwjODMyjFmoi8MJRCf dDhFwUgzHhEfG/8I1Qg7KrBG7Crz9lPVWk5qe+WYi0MTtv3ZN9nLmsTMDMwmdbsD2L57 OQPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681431120; x=1684023120; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LGz+M9nFtzHbGGbLaqDB42+XLCRk5tnoOBaeHE6w0dg=; b=B2aroOwC1oD8ILdHWIDbbnAanFHWE2GTwyzQ+PdwDTdcNB5GWSw+7tGGsGXmAv5Weg NDOr5wSnBVdvAmCzBCLfXHZW2Y4Eo18VOejZFnucK34k684ElJwrHUbUlNwCrLjfSC5+ RyGkfL0BpvOaZuV5cSGybLmD2RiR0FSmD16gSKXk9X8i2Wlp0zoNYPqAIKmhAYlCEOLo lIvOrx8vyRCyD5Dl6TcaPGBDZmObtiBoKzUNK4KRoLlTI8+tCTNSznXlHUtP4lYsHvbZ jTRg15/54sf6mmbcN0O1+9OQ8kuUFhrV516ZcSnrtTzOA0wmP9GfXod8pS+Ek7S+IzBn 7Lqw== X-Gm-Message-State: AAQBX9e2qcMD+n+/S8OjVb0KdBBArMNKNEbcQWOuuckUuGrkH1IDNvkt GzONyL3PeMf7sb18qXsL5msEvrrUsj0+p8+6gw== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a17:902:bd90:b0:19a:f9d9:28d4 with SMTP id q16-20020a170902bd9000b0019af9d928d4mr282396pls.3.1681431120479; Thu, 13 Apr 2023 17:12:00 -0700 (PDT) Date: Fri, 14 Apr 2023 00:11:50 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <476aa5a107994d293dcdfc5a620cc52f625768c2.1681430907.git.ackerleytng@google.com> Subject: [RFC PATCH 1/6] mm: shmem: Refactor out shmem_shared_policy() function From: Ackerley Tng To: kvm@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, qemu-devel@nongnu.org Cc: aarcange@redhat.com, ak@linux.intel.com, akpm@linux-foundation.org, arnd@arndb.de, bfields@fieldses.org, bp@alien8.de, chao.p.peng@linux.intel.com, corbet@lwn.net, dave.hansen@intel.com, david@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, hpa@zytor.com, hughd@google.com, jlayton@kernel.org, jmattson@google.com, joro@8bytes.org, jun.nakajima@intel.com, kirill.shutemov@linux.intel.com, linmiaohe@huawei.com, luto@kernel.org, mail@maciej.szmigiero.name, mhocko@suse.com, michael.roth@amd.com, mingo@redhat.com, naoya.horiguchi@nec.com, pbonzini@redhat.com, qperret@google.com, rppt@kernel.org, seanjc@google.com, shuah@kernel.org, steven.price@arm.com, tabba@google.com, tglx@linutronix.de, vannapurve@google.com, vbabka@suse.cz, vkuznets@redhat.com, wanpengli@tencent.com, wei.w.wang@intel.com, x86@kernel.org, yu.c.zhang@linux.intel.com, muchun.song@linux.dev, feng.tang@intel.com, brgerst@gmail.com, rdunlap@infradead.org, masahiroy@kernel.org, mailhol.vincent@wanadoo.fr, Ackerley Tng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor out shmem_shared_policy() to allow reading of a file's shared mempolicy Signed-off-by: Ackerley Tng --- include/linux/shmem_fs.h | 7 +++++++ mm/shmem.c | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index d9e57485a686..bc1eeb4b4bd9 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -134,6 +134,13 @@ static inline bool shmem_file(struct file *file) return shmem_mapping(file->f_mapping); } +static inline struct shared_policy *shmem_shared_policy(struct file *file) +{ + struct inode *inode = file_inode(file); + + return &SHMEM_I(inode)->policy; +} + /* * If fallocate(FALLOC_FL_KEEP_SIZE) has been used, there may be pages * beyond i_size's notion of EOF, which fallocate has committed to reserving: diff --git a/mm/shmem.c b/mm/shmem.c index b053cd1f12da..4f801f398454 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2248,20 +2248,22 @@ unsigned long shmem_get_unmapped_area(struct file *file, } #ifdef CONFIG_NUMA + static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol) { - struct inode *inode = file_inode(vma->vm_file); - return mpol_set_shared_policy(&SHMEM_I(inode)->policy, vma, mpol); + struct shared_policy *info; + + info = shmem_shared_policy(vma->vm_file); + return mpol_set_shared_policy(info, vma, mpol); } static struct mempolicy *shmem_get_policy(struct vm_area_struct *vma, unsigned long addr) { - struct inode *inode = file_inode(vma->vm_file); pgoff_t index; index = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; - return mpol_shared_policy_lookup(&SHMEM_I(inode)->policy, index); + return mpol_shared_policy_lookup(shmem_shared_policy(vma->vm_file), index); } #endif -- 2.40.0.634.g4ca3ef3211-goog