Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp335336rdh; Wed, 7 Feb 2024 06:17:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzDVTMHmvK57dYWWskKrBg4QXTyKgUdX4wmG1Mc2jTdw8hgczfGGQ/oCDoIdUhInaY3V14 X-Received: by 2002:a05:620a:124c:b0:785:91d2:25e9 with SMTP id a12-20020a05620a124c00b0078591d225e9mr4209431qkl.7.1707315465780; Wed, 07 Feb 2024 06:17:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707315465; cv=pass; d=google.com; s=arc-20160816; b=MiBVnvFa+FSvtWxztNe8vtKLvR+MwPhKnvdr8jlVCRdL4NkgHaQgaYgsQ+P8D8RrFs 3fMqYCENMymJCzUHjIQW8KRdgK6MpxEmY+r4zjXfiCwHpH4KkyX03WXo74drltrL+ixr 8PsBsw1p/a5sEua0ebssi4TS4vKRVCJch99Mg1mfIXMwCcU6flSzKrqvQfadwmuR4ARK qhKxuTolkGH/WL9VPumDVLfUvfuo3hDTJJM4oyp2VOHnO4upP2oHSEkCp5ifNf6PcKJS UssrhxpaRZgt4UZKjXhT5qHXaNpLAzqRxKlVyLU7GZ9iA0/8rdhZHC1a2eOFqh4EwxG+ 2S5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6nXIcLmaWrCikPStJ3sC7+E3lnqfPQhTFLM5Qd6/v+g=; fh=nDBsM1pfpZH9FSQp97wiEajpyU0oh5SqXL79TxcpP+s=; b=D+xikXkZ/HuswQPhzVVhsfCc6QbyfroZIThaqbwJ0M+j8i+eEblGP40rpOp1XKrmTf DbaVvXQInvxWODPdE3zhotflf4HL1ZIi3A/FtNinwqc9F49BjeS4t9h1bXmpgca2EHAD 62f+PKDUGbqnOcpn1mCfKnODz17Jymd0LmDEEm/WFTF+HMVlCD2PR7wVh738Ii4ID+xM W/5mwVOQQLJ6WsgeAI3vcux0jTRKmr4DebVsH6QPdvokarMkMo+848b7Cq+Q9jWFN7Wg RVkrcw/aA+nKZcFnjQBWPKmCGU6TQyRS0jz7bQtPhEJsr5ukvt01kamgxsnO4OUilLj2 tSRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cdkGZZ6H; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-56605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56605-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVulBGMB3hyZpRtOZOhf8jd/e6a2zhMjvNy56ONCRgUvTZTlhQU13IQ6cjDJ4M5qe4EjJZ9LKUsGY2mPX0hxwnkLB/GVd36i1HwtoOlFg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j25-20020a05620a147900b007856007f798si1113955qkl.499.2024.02.07.06.17.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 06:17:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cdkGZZ6H; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-56605-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56605-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 860571C23F24 for ; Wed, 7 Feb 2024 14:17:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8F5E7C095; Wed, 7 Feb 2024 14:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cdkGZZ6H" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8430777F2A for ; Wed, 7 Feb 2024 14:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707315459; cv=none; b=r7eDbvtJJ2PrpyE9VI6FRY5LN90MsOUIIwltiLSF/SAY+pPXC1Gb9ZiT6aePYmnLF6aM/V6A69NThESQF+IT3fSPSy2NaLE1V4xJz0ML0qfzkKeG20FHf+5pVWCa6UjD8+mGURMdX7dzSnR94B1AT+xbVqdugfzHyIdr9j6tdqI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707315459; c=relaxed/simple; bh=1FoXys9DjqAW9tBcBEYCUR2iy5mCIoqQk2Y8S3+GmpY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rklJqX0SzdlpnPZKaruCeSldggG+VSR+UqRWkqpdQSzPdseicjeLMxx0cwy1Bug9iMg5roujJZhmCQAIvyEPbX7nSZeDBx4CyF6vZO2jq6lMU5FHpAoLJrckC/4jp3SJNA6btHcQbfVehFqYuU973Ab4vuARyx0LLJep2VmwswI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=cdkGZZ6H; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6nXIcLmaWrCikPStJ3sC7+E3lnqfPQhTFLM5Qd6/v+g=; b=cdkGZZ6Hx+vVpgO8vYvlPMpbTQ K/alL+Cx5LLR6Ap1iO9ffjd5Zemo3g7Yxeb+FVj0ctQakDgQOQmp/0dejt+dxj2jLyp4yuy3JsQSl SWiQnhSIOO2KsCP0NzIQXMSuEDLhc6pNebUYzIpudZECGPlJ3SceMr2VSHPYwtJ46sjub2r/tqNF4 kKUBc3VzfT3CfuU20g2Pv1nkSocvbqOg+93mDqfoNVrSMFrUn1qltiUiiojz4RTO5nha4YNl/qpvk O5E1WZOrF1yaNXlVVP3qW6qg/J3DYr2vx8qLnzEzHPWkFOMOSXNAgyA4kg3QqHRKbeqa952oZ5/SU qJtjatFQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXijz-0000000FJjg-2Fbc; Wed, 07 Feb 2024 14:17:31 +0000 Date: Wed, 7 Feb 2024 14:17:31 +0000 From: Matthew Wilcox To: Will Deacon Cc: Nanyong Sun , Catalin Marinas , muchun.song@linux.dev, akpm@linux-foundation.org, anshuman.khandual@arm.com, wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3 0/3] A Solution to Re-enable hugetlb vmemmap optimize Message-ID: References: <20240113094436.2506396-1-sunnanyong@huawei.com> <20240207111252.GA22167@willie-the-truck> <20240207121125.GA22234@willie-the-truck> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240207121125.GA22234@willie-the-truck> On Wed, Feb 07, 2024 at 12:11:25PM +0000, Will Deacon wrote: > On Wed, Feb 07, 2024 at 11:21:17AM +0000, Matthew Wilcox wrote: > > The pte lock cannot be taken in irq context (which I think is what > > you're asking?) While it is not possible to reason about all users of > > struct page, we are somewhat relieved of that work by noting that this is > > only for hugetlbfs, so we don't need to reason about slab, page tables, > > netmem or zsmalloc. > > My concern is that an interrupt handler tries to access a 'struct page' > which faults due to another core splitting a pmd mapping for the vmemmap. > In this case, I think we'll end up trying to resolve the fault from irq > context, which will try to take the spinlock. Yes, this absolutely can happen (with this patch), and this patch should be dropped for now. While this array of ~512 pages have been allocated to hugetlbfs, and one would think that there would be no way that there could still be references to them, another CPU can have a pointer to this struct page (eg attempting a speculative page cache reference or get_user_pages_fast()). That means it will try to call atomic_add_unless(&page->_refcount, 1, 0); Actually, I wonder if this isn't a problem on x86 too? Do we need to explicitly go through an RCU grace period before freeing the pages for use by somebody else?