Received: by 2002:a05:7412:a9a3:b0:f9:93eb:408e with SMTP id o35csp4982rdh; Wed, 20 Dec 2023 20:16:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpi1q0ISWjqPiME/Y7ZArm9KVKTeiJQDCIQ5FPF6TcWLIwq2HlMZI5k8K7vXx/2XAVOB1t X-Received: by 2002:a05:6e02:3499:b0:35f:d55a:c4cb with SMTP id bp25-20020a056e02349900b0035fd55ac4cbmr543063ilb.50.1703132214784; Wed, 20 Dec 2023 20:16:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703132214; cv=none; d=google.com; s=arc-20160816; b=qOawhG2xegHBu2FERskKSlvRoVYkrjUNnYhHsiTtja7MbMcaRYklkWmXqYNr+FPq8S ckZiVilNY98CDNWs2mVIUwJBdOurBpAN2Vx0C1KcF3Fqd6Lm1mIMtCzxuW2YSAAvxpET Qz9cospyRJNm+dMFWoJ2EVbsQRQlbCKPHJ1Ru5bJZ22uD4hF0DzUaX63PTFqlSgHVz9q 9S/3LlHZ5BO0vQEi2e5JUm0DQ9o40CDz5+MOSfHJytQxHpOxywDyK2ye+jxd+c2262B0 9elngvQMG4WmHlXrxCJ41nN2jX5BjIYCkWcW+CTjk718vmZDZLBJwQtiN55/PcLGuCJ+ UfiQ== ARC-Message-Signature: i=1; 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=9fu9ycNjYnh+jMIffCCFUrHb5XSgNNhRHsHudZOD1U4=; fh=4+SHNY9YLzUlbs1040KA1UenKB2V4hjWX1MHPotDVY4=; b=TlRebGfKerUxg6gv+Q3G5695azYGomjedv8I8VFHRpPiHuHGODoEskju3KQrpU9UMN e2PCQrLatydWihTQRUuvK3CwtYHzXsiofs6wfmFtkmTae846bF68KHrzBgzEGI01K8jN oQyzMwyOOmE9I36yIwwtUG7COy2dgG82pH+gCWhRVD9vwU6j3UdeRtX/nIeafJ2ia2d1 p2m+scVtTP4Q9R5KLTtnke0dY5PwJ3ntyLv2D/rB75yG2EyZNuUsi3MdZOeBXAMPn/o7 GKGLAOF6I7WmBqR699f3xSpvgq9k1tAq4xRd1mcDguHEto+mAqHBEvEIosIIw5d9RR57 04ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hKekoeAY; spf=pass (google.com: domain of linux-kernel+bounces-7831-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7831-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k3-20020a170902694300b001d056bdad56si775465plt.166.2023.12.20.20.16.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 20:16:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7831-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hKekoeAY; spf=pass (google.com: domain of linux-kernel+bounces-7831-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7831-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 25637B21E99 for ; Thu, 21 Dec 2023 04:16:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 619837481; Thu, 21 Dec 2023 04:16:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hKekoeAY" X-Original-To: linux-kernel@vger.kernel.org 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 00127945A; Thu, 21 Dec 2023 04:16:40 +0000 (UTC) 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=9fu9ycNjYnh+jMIffCCFUrHb5XSgNNhRHsHudZOD1U4=; b=hKekoeAYg/rDawz5RlczPsQxTw FbJT6TQ/p5XH1uX/o1xNv0G7RwUKs979dkcSf9bdh8J2O5Ndx6YwfkTRl0DgPUhrKo9+pDTHkbn/O BomJKJeDHCTiFPP5arVtnHQTwF55V060pPAjYwVtcT4Wo62YpeSK1DKMb9BSaiNpfwUn/uQnw/PY/ d71QvyIk992VEnb1fbjUdMhlwUQFrEv/6o+ooZRLpFtS16cvZERfzA2k6zay9yrT+GJteQT4COUjO 0tSA7ljvQDKMUK7eQhLODDSWWxnYyvr5nRpz5THDzpQ9TMs0ELWTP6UbEPs3/euDXKsl2ai0lk/68 /GjocBuw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rGAU6-004eJy-UH; Thu, 21 Dec 2023 04:16:35 +0000 Date: Thu, 21 Dec 2023 04:16:34 +0000 From: Matthew Wilcox To: Pasha Tatashin Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rientjes@google.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, iommu@lists.linux.dev Subject: Re: [RFC 0/3] iommu/intel: Free empty page tables on unmaps Message-ID: References: <20231221031915.619337-1-pasha.tatashin@soleen.com> 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: <20231221031915.619337-1-pasha.tatashin@soleen.com> On Thu, Dec 21, 2023 at 03:19:12AM +0000, Pasha Tatashin wrote: > This series frees empty page tables on unmaps. It intends to be a > low overhead feature. > > The read-writer lock is used to synchronize page table, but most of > time the lock is held is reader. It is held as a writer for short > period of time when unmapping a page that is bigger than the current > iova request. For all other cases this lock is read-only. > > page->refcount is used in order to track number of entries at each page > table. Have I not put enough DANGER signs up around the page refcount? * If you want to use the refcount field, it must be used in such a way * that other CPUs temporarily incrementing and then decrementing the * refcount does not cause problems. On receiving the page from * alloc_pages(), the refcount will be positive. You can't use refcount for your purpose, and honestly I'm shocked you haven't seen any of your WARNings trigger.