From patchwork Tue Oct 3 09:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13407337 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 DCD82E7543A for ; Tue, 3 Oct 2023 09:23:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 781216B015F; Tue, 3 Oct 2023 05:23:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7327A6B0160; Tue, 3 Oct 2023 05:23:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F9976B0162; Tue, 3 Oct 2023 05:23:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4F2546B015F for ; Tue, 3 Oct 2023 05:23:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2C0FDA021C for ; Tue, 3 Oct 2023 09:23:05 +0000 (UTC) X-FDA: 81303611130.26.517221C Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf10.hostedemail.com (Postfix) with ESMTP id 5B329C0002 for ; Tue, 3 Oct 2023 09:23:03 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=JqcSOboz; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of hughd@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696324983; 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=Mzr/4uL62aOMXHcIAqfjDQcxRGe9jlWGjvKm9366txw=; b=6mbXda+eACbazk6btZRBz4njyPlVXWCWYOs0GLUXEpbfvNqRDKoyrpEB3xhAFm9l4ywfbY +LQGt95nEIBCwG6WXw/GJ5plyQtWwUhxLb3Iz4Ql/O92sHOpWfaAGNHt+LEo85i/UgWX5L zMLG2WY1l6zOQw4QK5b3lz40BZwnXY8= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=JqcSOboz; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of hughd@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696324983; a=rsa-sha256; cv=none; b=bEtbjsjDFQmguEVrFyctnRgLQbYODyN4FgYyzd0EX/rPo151F5G5GN9h2DpdO5gt022f+h u5+YbiFTQajfx+ib5hEJHcCmIMP1qZLP5tk7qUlb3sBEZJddYiDwlDcdQ1UXWyd/J37nXO UJiMFkNoOgYb3rpuPLSQ6lq+Mi9Aamk= Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-d865c441a54so734842276.1 for ; Tue, 03 Oct 2023 02:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696324982; x=1696929782; 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=Mzr/4uL62aOMXHcIAqfjDQcxRGe9jlWGjvKm9366txw=; b=JqcSOboziOaz1RhDZa8GQqho5kUUhuanF8M7SEtTrtE0ohUxk771I4hFVCb0BpsAAM ALXHZESU7TkbAY7HjwiXjHiD0IxUF8AapyNesJPrWG4gr65letMTiecImyUvIVslVv4F 2xVLEVLJchnm1Jow2RcCNLlYS3H0iWrTxqBCW/JJqtITqysnGoQzbdFTiK7A36W9YBdF Y+iBxi0rlx9ZYy105+YWq4X5pgXKpCPKGFy+UVljXUUD/yJLeCRWeXKxDh9r3/q8mMnl H+46dSEbVsF86Wasp1I8nh2WG3IdoM92za6K9wVH5olv2jw6pcut21hgCmbAAUGZ8iL7 LvDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696324982; x=1696929782; 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=Mzr/4uL62aOMXHcIAqfjDQcxRGe9jlWGjvKm9366txw=; b=ZulKae+sLXyIr61eDi/lCqhxbXG5jFNgek9eVfsxhGAVMMgOYccpJ5FSqIxUT9s4JC UO7hDLDIx3xgQvGH44Xe03UJpMH0pwTyKA3u+UV/+Z1hl4iqtwQCELhLVd0aJKP1iW51 ObQ8m9763z5CimhLnMhZkOKG7Yh4HQf6QeUL3D72U35sgCJ9lTQTDSL0EVBY+PTzhfRk 9r2P2rKEZK6YrtdORslUr04E2WvomzRvpOPQ2KwPo9fMQdjZPonyj4HwPZiKNPuPep2I 6FEd4ZST6fJO+W/FWcUNDsOsO0j7hMa8BX2IzTgG9KtCtu5PrDQzFQOM9sIwW9r1QKIY EEaQ== X-Gm-Message-State: AOJu0Yz8sk6z5cglyBDnN5UtvlzaBe8eBuUvMVrmbwquV/ufg6y+SfqE rZ5kMrD/z7b9o3TpDfBiWsQQcg== X-Google-Smtp-Source: AGHT+IFxboDdNa1UhQmoXRYSqnKITzmYFNT7NTostAtgCQUNJAxTZwIq6gRE4Eb16MSOzmlZgLi7Uw== X-Received: by 2002:a5b:c89:0:b0:d81:599f:a538 with SMTP id i9-20020a5b0c89000000b00d81599fa538mr10809754ybq.51.1696324982333; Tue, 03 Oct 2023 02:23:02 -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 c6-20020a259c06000000b00d816fa23bd4sm280649ybo.26.2023.10.03.02.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 02:23:01 -0700 (PDT) Date: Tue, 3 Oct 2023 02:22:59 -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 07/12] mempolicy: mpol_shared_policy_init() without pseudo-vma In-Reply-To: Message-ID: <3bef62d8-ae78-4c2-533-56a44ae425c@google.com> References: MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5B329C0002 X-Stat-Signature: 5jjkn6c31wrwg8wrtmoz94on66w6h1er X-Rspam-User: X-HE-Tag: 1696324983-300103 X-HE-Meta: U2FsdGVkX1/hpjOqNt8NRwA3xrqKJ8vMlf8R9rzSige1iQ4XDhrkLLP124TXkc5odgxdcFbx4B4i1yil4q8/033lK5QnSoEVjVoRAuW+MYFTKZWb5e0wBEOjuwkGREs5WMMZbTaxWaQo78m7npx3nMSRNKswE6iEiQRSXlAV8HNqiRYdAPR1a+SJbQMVXcDBNRlVb4IDAe1P9TFjqnS0WyEnUd1fdQSSBfGmY91m/pnoviNU+qq19kJe6xJU5v8efj79lJ3LazktadPQsWc0hNe2xMCeIUW3pLimSRZvy1C6E8gbewNq4bBF36Qeo3StagUH/uaHwecmcoGVbkk900hO9mhV1Bqt06MbyBzTWDwQ5FEcQyHGMWKegGdHikex8EQUdARTBnzH51j1Xr+oO2I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zUBWpdA4ZfdVgIpJ 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: mpol_shared_policy_init() does not need to use a pseudo-vma: it can use sp_alloc() and sp_insert() directly, since the object's shared policy tree is empty and inaccessible (needing no lock) at get_inode() time. Signed-off-by: Hugh Dickins --- mm/mempolicy.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 1d3f9e1ecbb8..5d99fd5cd60b 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2756,30 +2756,30 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol) rwlock_init(&sp->lock); if (mpol) { - struct vm_area_struct pvma; - struct mempolicy *new; + struct sp_node *sn; + struct mempolicy *npol; NODEMASK_SCRATCH(scratch); if (!scratch) goto put_mpol; - /* contextualize the tmpfs mount point mempolicy */ - new = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask); - if (IS_ERR(new)) + + /* contextualize the tmpfs mount point mempolicy to this file */ + npol = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask); + if (IS_ERR(npol)) goto free_scratch; /* no valid nodemask intersection */ task_lock(current); - ret = mpol_set_nodemask(new, &mpol->w.user_nodemask, scratch); + ret = mpol_set_nodemask(npol, &mpol->w.user_nodemask, scratch); task_unlock(current); if (ret) - goto put_new; + goto put_npol; - /* Create pseudo-vma that contains just the policy */ - vma_init(&pvma, NULL); - pvma.vm_end = TASK_SIZE; /* policy covers entire file */ - mpol_set_shared_policy(sp, &pvma, new); /* adds ref */ - -put_new: - mpol_put(new); /* drop initial ref */ + /* alloc node covering entire file; adds ref to file's npol */ + sn = sp_alloc(0, MAX_LFS_FILESIZE >> PAGE_SHIFT, npol); + if (sn) + sp_insert(sp, sn); +put_npol: + mpol_put(npol); /* drop initial ref on file's npol */ free_scratch: NODEMASK_SCRATCH_FREE(scratch); put_mpol: