From patchwork Tue Sep 10 23:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13799497 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 6D664EE01F4 for ; Tue, 10 Sep 2024 23:45:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4886F8D00E1; Tue, 10 Sep 2024 19:45:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 389248D00E2; Tue, 10 Sep 2024 19:45:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0022A8D00E1; Tue, 10 Sep 2024 19:45:18 -0400 (EDT) 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 9081E8D00DB for ; Tue, 10 Sep 2024 19:45:18 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 524F114066F for ; Tue, 10 Sep 2024 23:45:18 +0000 (UTC) X-FDA: 82550462316.04.2D35CCF Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf29.hostedemail.com (Postfix) with ESMTP id 71567120006 for ; Tue, 10 Sep 2024 23:45:16 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=XKwui3Wm; spf=pass (imf29.hostedemail.com: domain of 3CtrgZgsKCH8dfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3CtrgZgsKCH8dfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.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=1726011888; 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=lBJef16ALyOYFlot9YzaY+1ElfdQQGF78ZnzsjyO0V0=; b=fhrQwc8mN3NSmCEYPvLYxhnkr9SI8+d9WHDbVFkOxujiL5QmxKYyKFHwQQZp0xDO/ZW4yi bYEW9JWYSvZwN84UnncJs581MT/XfRCKegH9ORGb30DnmhynT7v0R5kIaY8cx7Qp0uHP+7 1NUJ2syc5TyhOeDvL6gHiruyfuTzHz8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=XKwui3Wm; spf=pass (imf29.hostedemail.com: domain of 3CtrgZgsKCH8dfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3CtrgZgsKCH8dfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726011888; a=rsa-sha256; cv=none; b=juPatSvmruJKqYlkHksCUK3MswOc1uJczWAv06fNKocf7x+sux1fMds6WcNXqknvWYW9Kh Z2us+Bd+5EXzQBt99ved5QqXq5qnfJfM141d0mGYwFagW9Z3o8Jfz78u17Hz14vP8Y5+yH ++XjIxRMIP1O1z0uCBNfnvQx4ihRCQw= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2d8dd20d0ddso308952a91.1 for ; Tue, 10 Sep 2024 16:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726011915; x=1726616715; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lBJef16ALyOYFlot9YzaY+1ElfdQQGF78ZnzsjyO0V0=; b=XKwui3Wm8yjuizkujdDJx03d6t+lTIuv701dpbgUs6ipEi9JXQh6BxzFFbgAOCIPkp yhmab6cJtOPm/vwAei+gi1eyudZKHL3NBnSy/ix5bnBZNwhP3YNIDoeymudUtPL6ksg3 jFsfiwtRIx2AVN3zVItGmIIVEPVOEQO21svAFSH735zYsUnTLW7hA4KXdD8e3lCsDQBj njX4i25Sj7ZbRoODFWDPeadkSUcwAcNqS18dH2dHQKvrkVT4V/4xzWvARE+0/misFXOm M+cgvjxvomKn+bs812Fzd7oIxSUDq6UsYa5n+jR/8Z9w5Dyd0Dqdy2WEjjT9hjlKiBSx HD1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726011915; x=1726616715; 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=lBJef16ALyOYFlot9YzaY+1ElfdQQGF78ZnzsjyO0V0=; b=jN8FTcC38UwT/W6/Hz+otf+RyEKS7pcetlMgyrYKEik2Oraixt/vKvry1tuD7HGJh5 hrmutN7CN3ruGLLZ5hTmOcqAbQv4l1fR8EUw7pQIkuphNx8MaBPkgn0JUnqDPuFN1jFk +7bWPUxit81TIs2o/gORE/kiebvBNRtfL9mbmu635kVP9UmUts3yEZU5Y+1BWp7kZsKu dns1uVGcu+6vnul+OEZJcOwLcJ/+LqxPkuDYi5PsrCKHjpyWBTnQPugfpl+coolhqAQJ NZBOxtx4YYu8OA6WPEbenho/VJCY4Y5YGbbF1DFHASvInBP3BZza0gB7udtGdP8gOnLM CHSQ== X-Forwarded-Encrypted: i=1; AJvYcCV8Yb7HpasMjmI8ZTW6DNbaIXWnMmyScq1xgb6CKXnx0IpkQfmpexc/jI0ifsxwiQyX2lSwpQvsnQ==@kvack.org X-Gm-Message-State: AOJu0YyfP51tMEa3+o0PE0vR4A8fBOx250sK65GrLGlkTOttrbp056vt xasDXWrdQT/IVXXYvhWKWC0F38JfU+cqPwEYSTsAZJiEuYcoQxDkH62ZbdFyH0FeWBPv8VTSN/2 fgZsK6WUn7ShgW5jixHewcQ== X-Google-Smtp-Source: AGHT+IE6UzsGakpseqVGpYmVeT4krDva7uEV1yzairw6T5Hn14xupYXurGRjEZiCuCr5K2NNFKPuVFRVzmSBBIl0nw== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a17:90a:d14d:b0:2da:6d50:e79c with SMTP id 98e67ed59e1d1-2db67176e9fmr38917a91.1.1726011914978; Tue, 10 Sep 2024 16:45:14 -0700 (PDT) Date: Tue, 10 Sep 2024 23:43:55 +0000 In-Reply-To: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <55b2d15ddd03b4c7df195cace3dff83ffcbfa71c.1726009989.git.ackerleytng@google.com> Subject: [RFC PATCH 24/39] mm: hugetlb: Add functions to add/move/remove from hugetlb lists From: Ackerley Tng To: tabba@google.com, quic_eberman@quicinc.com, roypat@amazon.co.uk, jgg@nvidia.com, peterx@redhat.com, david@redhat.com, rientjes@google.com, fvdl@google.com, jthoughton@google.com, seanjc@google.com, pbonzini@redhat.com, zhiquan1.li@intel.com, fan.du@intel.com, jun.miao@intel.com, isaku.yamahata@intel.com, muchun.song@linux.dev, mike.kravetz@oracle.com Cc: erdemaktas@google.com, vannapurve@google.com, ackerleytng@google.com, qperret@google.com, jhubbard@nvidia.com, willy@infradead.org, shuah@kernel.org, brauner@kernel.org, bfoster@redhat.com, kent.overstreet@linux.dev, pvorel@suse.cz, rppt@kernel.org, richard.weiyang@gmail.com, anup@brainfault.org, haibo1.xu@intel.com, ajones@ventanamicro.com, vkuznets@redhat.com, maciej.wieczor-retman@intel.com, pgonda@google.com, oliver.upton@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-fsdevel@kvack.org X-Rspam-User: X-Stat-Signature: xkqnj474xb6tc6aa4tpsqcuhtw4d7rs7 X-Rspamd-Queue-Id: 71567120006 X-Rspamd-Server: rspam11 X-HE-Tag: 1726011916-198998 X-HE-Meta: U2FsdGVkX185pnE0eD2a85jy18sbuh5RhIyN2NzOhbZEUlDTJkkZ8TywGa80i6bt5bDgjTZiZveMWMoyXxizbJnevg6VC6bUxYcK0zANmICHFFl61yvOXl1SmC4a9WPUaFemEgqvnItEEYgnlfOAdKhFTncbcHJHw83Gjhp4Bn3Rsd0Y/xZXctTxPTUDqnsSxSdlhdjSNhdmfvzMA1EnA3/we91kUiZ/yth7bDsspM2MYz6kK2EF6QhiswYSkAvxuL8j70mXQ1BnLGTvoEC5iVKh8GP+tKcMro7bTyxg4AwipQL+sCjVL1V51q+jFbbHWucsk9wKOHOVZgmoFzNfgrK6SjVQ0PPU32MLxAdgQpfwKVWtYh3xpiTxfHzPtZbo0lt7f2mupFsiDikmbQ2MReu4Pwt1MYu6koXXak3F6djT8LwFIcI7upwjbwsChPziMH0r4wyyt2hNrFbTFFMGFvB3L6WiNWxUz+BL6yIYoNZSfTmr+tUtwpISRFm4xUf8HTZkgcnpBUaF0KKgHkTnzIp1tCI8d8Q18QyAKOE4aMu1zh2Lw0j5qMIu6UGQOoHgKkXJJS9p5JYWbj7YypB5OLnSr803g6lWa3YznFTLma8/x3rg+yPjnLkY8oEGYD30fi4iraNCuDKvvKLovOR1KUtdIR/ywoMFad4Dc327j12VgEr4ebg4V31WGJX8igFyvMICDGqpHC/pYkThHJ58venbVy59YqZB+11kVworEbyzfqwipYlfXVxA5/qCqKtuBYUXm2N3c67v7hfuFsYIrTbRsqrFnHxIyElJLc4wCVJl+ENMEwNimbqyVVpoXZRWah1h8CtLoEHNcW0uUK0U4JqB3BKODmFkAd3crL9MvSaFPrV5iLw5+j+0VBzynlWQM/radFH4OFcrm4A3FD+M9KmD2CMwrSU0IRDAC3KgRqpUmivB1FTZ1LPC3PqX6h2ORdmqCk6jzk37yDyZGK9 9IcDnJuh TDGsIf9z9PirzRmZbUUOr4a3HqDOh+LIcjfpPfbm3En0CTqfNKIvr4HFARoULSLCa7UJPnx78k7Ecxz2S7ouYyt3olUyZ8lgG6ABfeszmsyEehjO304Di9/r9TdoY8lW9aSJ/F1eFeiKQAvyE133lBCZ3FbiO8RNketdOsFAD6rYl+Bn/pJ5JQ1VPZ/LAqRyoP4xT48iRkc+v9v9OHOtq8zCOBm1Z56ROhBPcCEmcqGhSyYoR7pwQb9f0v6D7lcABhEuUNUMY3qk01kS/yeiXevhpXBe4UEoTixfmKCrMD8FpX/0GM0k05tUf9FWw22Oun+ncIoIVB4M7B4xlVZfrFOKEYf6vRNz45OTotwtv2BHaUVJzIPYn4JgB8HkQ/Smq93VSNuzR65g7qKy9kQnizcPpI2ERATEtoX/FH8fYpjn00wiRfeUQS+5W9tbDeEE2RY/mU2kPRmNSz3asibMHHuuk5S78VOmNTibU27ZfucZex8riCUElj4oO/3Gk/6Y78LyQyMR/PRX3Up7o+Rix298InPOx0kuLkuyDPR3SLZIYqwmSzQUju7IzKCYU1qxLnKj1mo3vlNnnvMha6VtWGsjsdaxT3mkJEZysXBGUwpeAU7/ivj41H1fiHBlAo/R0+YwI8dauA+xklgdiQEgMn13bfWYStsy41iBigs6+Xv8YIICSTBcTF+wnBw== 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: These functions are introduced in hugetlb.c so the private hugetlb_lock can be accessed. hugetlb_lock is reused for this PoC, but a separate lock should be used in a future revision to avoid interference due to hash collisions with HugeTLB's usage of this lock. Co-developed-by: Ackerley Tng Signed-off-by: Ackerley Tng Co-developed-by: Vishal Annapurve Signed-off-by: Vishal Annapurve --- include/linux/hugetlb.h | 3 +++ mm/hugetlb.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index ac9d4ada52bd..0f3f920ad608 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -164,6 +164,9 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to, vm_flags_t vm_flags); long hugetlb_unreserve_pages(struct inode *inode, long start, long end, long freed); +void hugetlb_folio_list_add(struct folio *folio, struct list_head *list); +void hugetlb_folio_list_move(struct folio *folio, struct list_head *list); +void hugetlb_folio_list_del(struct folio *folio); bool isolate_hugetlb(struct folio *folio, struct list_head *list); int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison); int get_huge_page_for_hwpoison(unsigned long pfn, int flags, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 8f2b7b411b60..60e72214d5bf 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7264,6 +7264,27 @@ long hugetlb_unreserve_pages(struct inode *inode, long start, long end, return 0; } +void hugetlb_folio_list_add(struct folio *folio, struct list_head *list) +{ + spin_lock_irq(&hugetlb_lock); + list_add(&folio->lru, list); + spin_unlock_irq(&hugetlb_lock); +} + +void hugetlb_folio_list_move(struct folio *folio, struct list_head *list) +{ + spin_lock_irq(&hugetlb_lock); + list_move_tail(&folio->lru, list); + spin_unlock_irq(&hugetlb_lock); +} + +void hugetlb_folio_list_del(struct folio *folio) +{ + spin_lock_irq(&hugetlb_lock); + list_del(&folio->lru); + spin_unlock_irq(&hugetlb_lock); +} + #ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE static unsigned long page_table_shareable(struct vm_area_struct *svma, struct vm_area_struct *vma,