From patchwork Sun Dec 1 21:22:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13889656 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 65AD7D4978D for ; Sun, 1 Dec 2024 21:23:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EC2D6B0096; Sun, 1 Dec 2024 16:23:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 675946B0098; Sun, 1 Dec 2024 16:23:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B8336B0099; Sun, 1 Dec 2024 16:23:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1304D6B0096 for ; Sun, 1 Dec 2024 16:23:06 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C56D616138C for ; Sun, 1 Dec 2024 21:23:05 +0000 (UTC) X-FDA: 82847665110.25.3CDBC2D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id AE477180003 for ; Sun, 1 Dec 2024 21:22:55 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LhBgKDiQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733088173; a=rsa-sha256; cv=none; b=eQ7xBl7a5dACPsx6W9TVi13cYb1/aF4n51symzjldf35vh5HWhWqgXpVE3/YzL0CVCjl6v aE22TidSR3G+MbkUsEegUPQPPhNWjFl1Z10Rp0NiUzPWgiZeuMmwCh/YnC5wrzzLAZhjxb PC48m6xsoMXyNpU/iYlPN+IrCLpOcjs= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LhBgKDiQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733088173; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XrrRdtWvOXhX0IC/Bu+h8sPnIUOX9C/tAx/abPzoJUA=; b=gl5n/KH38CAVwMeTFD/FTv0+h8oP1gSRZ0HCUxs2gT4Yp+v0dOVU7gsOLYhf6xVQqdM5rB VCphjwP+5CK+AA2/3LgK6dMlryufyEQSgyaBFXPnL/KCaNIo1jyEEPwUIRL8tWQPaiU4x4 FV+Pv0ja2c67WHBHc3DYM75G1ZXTKSc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733088182; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XrrRdtWvOXhX0IC/Bu+h8sPnIUOX9C/tAx/abPzoJUA=; b=LhBgKDiQDl8j+/F/EvFt6QOE3OP2t9T7HrxdTiEq/9zteFeFubVCBQecSciLiLniraoxC4 BerehIYgqh4fKB/Er5x2UYtSW1YG7bhf5eYjYL972qm4Lw67+YOj2QAAF0Z0HRg/9qeVrL w9ks7x0APO4ful2PcxC73eqge62iXIY= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-483-yClOXT-8Ml2-ZzRRV3D6-A-1; Sun, 01 Dec 2024 16:23:01 -0500 X-MC-Unique: yClOXT-8Ml2-ZzRRV3D6-A-1 X-Mimecast-MFC-AGG-ID: yClOXT-8Ml2-ZzRRV3D6-A Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4668d3833a4so88272811cf.1 for ; Sun, 01 Dec 2024 13:23:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733088181; x=1733692981; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XrrRdtWvOXhX0IC/Bu+h8sPnIUOX9C/tAx/abPzoJUA=; b=KT79IFKL08JNYlnC7AwlYYv9LiZFrRRzTY2CYuuWa7dpwYTW1xY5AOR+8Q+bhHWDfD VeslO1/h4yX6eOs+tRwfm39jH2RGo/ECrFzsJmi3Jj20B1QDAG+3j9GOmqXwDRKUPtyf ZgqTsIOhbyCDhxo0W2mIpPJHT3zv4RFMQxBkVML4ikCg493LLVbHt34yNCNehIFl4OxY jMYt8JCIitb/3bSpoYX+CzlOF+t1h1abPW2h73i/dr9ANMZT+qgsHbeQ24DQzHyWtkJK wvfa5/7CpojLbrqcqNYgR9RpBGSwhZnWbuZ6I9+a/F4SRGJV4wBY5l4OXF/CwZ8Gj+Wh 42RA== X-Forwarded-Encrypted: i=1; AJvYcCXBs27RAlBxlrWCIyASlTLFEFe6cZmtmlzBx7VkKyPKhgSl8F28MtlT7w62Zkl7E2N5SxkSpgp+Dw==@kvack.org X-Gm-Message-State: AOJu0YzFMqfoh9qgZde+LI1HzCEt5C0VQZBAMkJly2QiWMDF/wQwUBmU qVEEhl8/gQYGuzYKRKJVlc5k9atqw3oDFU5ZqCIYo37to9lSusMmlAiCNEMjxfxetPeJIZ4Xe07 +h6XRhOvIN/ykcg66N3Vo7uwIo6qQztaSPvrOYuvSexwbZD6H X-Gm-Gg: ASbGncskfm16hc+NK2s6bsPACfqF4GKZNTkIeJb6o/8+f1r5ns7goHuZMm9HA7xt7PJ jvTA/EK+aeW4q+U/2OI+Bhir4E9WeB4d74b31SOOzoSoQV96zfmCB53c6WA93zKYMvcwJ8TJ7Gt tRlsVe6aXjBAVhWsnMnXk++2EDtqmQM/7megwZwA/ECxFxMRNPB65hpuWp+GQWCZaEeSl5agmNx iyqFKhk2hh3VgG599m5W2yDdvD3Mrn3GGys1/vyeP3rMS0mw+iRs0SeLRDDpA+X8PUqbbNKrwDf DqQ5BhmBqk/BpoxCTU8uBtxMgQ== X-Received: by 2002:ac8:7c48:0:b0:466:a41a:6448 with SMTP id d75a77b69052e-466b359e3e1mr323828821cf.18.1733088180853; Sun, 01 Dec 2024 13:23:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMtpb17mmgqOgRNsdiR78ELm0LNQJM3Yg9dkXYjGdXNTa3Aa8RyK4xqT6Ebmoe6jg1COSs1w== X-Received: by 2002:ac8:7c48:0:b0:466:a41a:6448 with SMTP id d75a77b69052e-466b359e3e1mr323828541cf.18.1733088180557; Sun, 01 Dec 2024 13:23:00 -0800 (PST) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-466c4249f0asm41278911cf.81.2024.12.01.13.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Dec 2024 13:22:59 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Rik van Riel , Breno Leitao , Andrew Morton , peterx@redhat.com, Muchun Song , Oscar Salvador , Roman Gushchin , Naoya Horiguchi , Ackerley Tng Subject: [PATCH 6/7] mm/hugetlb: Drop vma_has_reserves() Date: Sun, 1 Dec 2024 16:22:39 -0500 Message-ID: <20241201212240.533824-7-peterx@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241201212240.533824-1-peterx@redhat.com> References: <20241201212240.533824-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: wS9Wh6lGoL1xLRaEslrI0qigWkriMWOwvALlrie2kuU_1733088181 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Stat-Signature: efgre8dkmeht6x1qrrioffh796hfmzrc X-Rspam-User: X-Rspamd-Queue-Id: AE477180003 X-Rspamd-Server: rspam08 X-HE-Tag: 1733088175-768133 X-HE-Meta: U2FsdGVkX19Xp2oCfPBBIYXhBBFICB33ReevOYkLeMo18UuF3XdJZfP2A1vtjqdRVUJJ00E7cNcXn+lXtUa2Zj5L/7s+vadvjCsP0xRGrS6d6od/xYZfMq+7ec9C2TFE4MpXnDxA9fdEFKzfgD2a13AFw8YX8zTVHcDz+dUNMjUJ1ueSNhHmRvRndVoQydvV3sPd5xiw2lnrLqw6yCo4PXnjU3lY/1sVVcys7WTYMSj9OZxZLH1iSxbeLaIkzp165HWhXUX8d5F9LBlDIR8xA9OQY92bu8r9WDQcm5VACkuryLQStidCle3EKY64vWpLLHQOSDasnHZshkZ27ETahv19eWj4NvBEp4Bcj+b2wk+GbBWdofnbMUGl/GNCJ9sU4BfxbsW84utsHD63OXaR1zuMeCAwD8mKa/M3dYdIGsebDIDAEKN7LFDSsAiDZ3FsCQm/2XtDL/ZCfzJ74HI+4VnQQsafgG3GuPXy3f4gu1b+TWKtPlbhCzG2Anu7LDMynKRw3MZ/TsKo5WHs+fJuuv4FtOs/zTcpnIHGDN8F0Krdt+mkgB6F9GW2pU8qa5D9ySlewhizxp9L+y7GNnfHa7VKfocIiwl4F8XwP4iFuVL3iFGWqNYilDGEdddCUiY6mY93ZTPlO8FTz5fut3pG4JBOG7EItPArN+SVfVKb54b2Bnkz8YJNYq0nH2fnQKOHawjAuGFsnJakJZXsF0OcCbN7Wo4tBoPd5BG8RrShl9iroCY2OEjlr3WT1TB9VUMtrP5wd7KDzdv275B/z7lubuX/3LZEsV2TF4H9iC3fsvgB3N2I0mHzyojEDXJ3tOYSMNaY/fWsfP5bWbGXBI0JbI/8sRWY9nBGfZPrGO/Cwmsnrz4MheJaaZwsaVjeDMRLND51YioTPNOMwsJ/0Vq8fE6HMAfcJhXpKqO800Dy08AK2yh8Ntk1weGdUyAhRXN/iEi2sKEd/r3hnNRoO7g 34y012OI Lh3YyFPZqCTIo0F+0/hCECwiOUYIy3a0/UEzx9/IWGVtx/DMn732MPrKDcZpMxrxN3odhtIRLp5fdMbMbN96ZxsFXy08qp1vZ7zXkKtvlu0hK/0DT3ke1IVWrLZ8bahHB3GJUP6tUNP5Ojy61vGtioX232DFMuC2YFxQA+sql4ToPIOcFD/WJb0LBhJLeG3hWX1vbgTIE4DpVkSZCgIoEFImaD1Fbyyj1/JPoWw70K2DdNsspwu5KSXMEjhDG1IUfFs2A2Y+3ClHivNKIvq+BQV0X/b+EePlste1sOTn711rDTPXnHVSJddVYnb8JzqM6pp8AvQRHMUqy6+ZF7VctVjq4j4gTLwcOMB0hS1dJyJdRIvEeF/Y7lvnLNGvCpK6Nm2zEjatrDgEFkiCB5s27M9LPuK7n3JP9Daf1crWCS9/43Hq/ouy68pOsZuv72cUhj8JEkQgf4CMGhePEJ3ZWvaYIe8SO5eo22MKeOjyAmfpKp+U= 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: List-Subscribe: List-Unsubscribe: After the previous cleanup, vma_has_reserves() is mostly an empty helper except that it says "use reserve count" is inverted meaning from "needs a global reserve count", which is still true. To avoid confusions on having two inverted ways to ask the same question, always use the gbl_chg everywhere, and drop the function. When at it, rename "chg" to "gbl_chg" in dequeue_hugetlb_folio_vma(). It might be helpful for readers to see that the "chg" here is the global reserve count, not the vma resv count. Signed-off-by: Peter Xu --- mm/hugetlb.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b7e16b3c4e67..10251ef3289a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1246,16 +1246,6 @@ void clear_vma_resv_huge_pages(struct vm_area_struct *vma) hugetlb_dup_vma_private(vma); } -/* Returns true if the VMA has associated reserve pages */ -static bool vma_has_reserves(long chg) -{ - /* - * Now "chg" has all the conditions considered for whether we - * should use an existing reservation. - */ - return chg == 0; -} - static void enqueue_hugetlb_folio(struct hstate *h, struct folio *folio) { int nid = folio_nid(folio); @@ -1341,7 +1331,7 @@ static unsigned long available_huge_pages(struct hstate *h) static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, struct vm_area_struct *vma, - unsigned long address, long chg) + unsigned long address, long gbl_chg) { struct folio *folio = NULL; struct mempolicy *mpol; @@ -1350,11 +1340,10 @@ static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, int nid; /* - * A child process with MAP_PRIVATE mappings created by their parent - * have no page reserves. This check ensures that reservations are - * not "stolen". The child may still get SIGKILLed + * gbl_chg==1 means the allocation requires a new page that was not + * reserved before. Making sure there's at least one free page. */ - if (!vma_has_reserves(chg) && !available_huge_pages(h)) + if (gbl_chg && !available_huge_pages(h)) goto err; gfp_mask = htlb_alloc_mask(h); @@ -1372,7 +1361,7 @@ static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, folio = dequeue_hugetlb_folio_nodemask(h, gfp_mask, nid, nodemask); - if (folio && vma_has_reserves(chg)) { + if (folio && !gbl_chg) { folio_set_hugetlb_restore_reserve(folio); h->resv_huge_pages--; } @@ -3023,7 +3012,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, if (!folio) goto out_uncharge_cgroup; spin_lock_irq(&hugetlb_lock); - if (vma_has_reserves(gbl_chg)) { + if (!gbl_chg) { folio_set_hugetlb_restore_reserve(folio); h->resv_huge_pages--; }