From mboxrd@z Thu Jan 1 00:00:00 1970 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 A29F8C35274 for ; Thu, 21 Dec 2023 04:16:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 395038D0002; Wed, 20 Dec 2023 23:16:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3452F8D0001; Wed, 20 Dec 2023 23:16:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 233EB8D0002; Wed, 20 Dec 2023 23:16:44 -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 14FC98D0001 for ; Wed, 20 Dec 2023 23:16:44 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DDD5FA050D for ; Thu, 21 Dec 2023 04:16:43 +0000 (UTC) X-FDA: 81589514286.04.E7AAE03 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 43A1F180018 for ; Thu, 21 Dec 2023 04:16:42 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hKekoeAY; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703132202; 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=9fu9ycNjYnh+jMIffCCFUrHb5XSgNNhRHsHudZOD1U4=; b=UYJboFFBUvhyHwN7Z9RXsxc+d2jTrCqkiya0BKVaywZRW2c6AoMjt6OfDi1xuEnQY54kPu JivnBSiVhU4XLC4rAfR5H9ztzZiZhlZHpWsWC9O3t/rdgCT4DK1WlvevEnJwPBkFbpm7Ur 04g3pUGvjBR65IvBVXUYYt3DXJyQdRU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703132202; a=rsa-sha256; cv=none; b=eea5dW3Yk0lShiOmIzY5kn0IbfM6T2n0hEhbd3JHccQipGfWIWxiiZVCXE9FEt4n+6Eryh a35NMahc5YxRRxJR0tos0uJZs8loNhjgRBpz4AYUicR57AGLstHtlBnTDqQze97gDam2qz 8REnTRLxP9jPOqqVuZfpe6Y/KcGvtKM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hKekoeAY; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231221031915.619337-1-pasha.tatashin@soleen.com> X-Stat-Signature: o46wwucgmzm4ach3nr3qy44o6zecey4g X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 43A1F180018 X-Rspam-User: X-HE-Tag: 1703132202-235209 X-HE-Meta: U2FsdGVkX19mX5wwm+AMq0lCewjtMSuQEQgZmzXzqwVglfk4vmIN28ehywEsJaSD1hVqioOyc6Ls6i9gSuH9KfPBbBwts7AAO1XpLmis/g74vuXIgo0NOCCkuFpMgAgCxKohQojbFUvPZ6unmEFdDxRi7vFZbtwrBIicV5abE58FTqxpGTNBEZBkFJrglEHSIEyu/VjIRGOp/6VA+pYuexlhHhsa4d5jPs7iLEJPNpweOUHP2IrWLdQ8oqvIvmZKY0S8OcUl5XejL8berQ9ozi2WamJGdxo6amYU+sqi6A8/SsqHis7TUqJMZ7+xSHhxiidPXaWp5u+hM9I49yMuZgYiMIj5/87NRMG6PeANtYbOBTnIjuZs7to6OSEGeC1CNhhChcuIMrjuhP7rXQGNmyyRhBDnTja8BIEfyfcBJZ/nLKABrupcR8AhPzJi3Seu/gSiNJKtaxjSFEaOnfScciHTDrlLpW2eOhfe/GJcjBIZnoAB56OqnVzL7nSeRzSr3I9x+1MhsD36UH2YwfE0I2MihktjG8lOQZ5revoNgLKL70mwhBf7ZXWoMuyqY1cc5phuiczyRlRKdOCyGLvOLAW4w6GDXAJ8DZtsOrfjyteKiYEvNiPBzar/Yu3TszN7ohBYo0/Tf8QGplqpHrQFJOUvnIQNt0a52Z3UXqRu+KHomb1y8kclvaQVrpbOdkveBqDMOjaJiA+8/5hVOhJy0FrW4JQFxsuodYuzSie8jc0pasdJgmXvCWItjaBk5Z12NGxSCq0fzScya3ko1zbMYN/+7r+NhRCCX7ZLZP6l7CRwlCCMpD8ET1RfyH57jHDNZnJOZTY64HBhXSlEbDbwtWSDAN94cAsPO1F5ooH5X8O68x52xDETHftlkNL0ZyK9wgCALN0l4Ov9s1m5UYcnfq97oiqrmiAK3cxJSRzz3vZRk5eju5jUCj3YpNYNtrzUSrna7zVM/ICi5220fG+ jbbomXXO OdQHSSlbOlUDvVjLVj/aXtQ03wM+VAc9YoydMVnXLV5Zbnld9ISXTaL1D73qxswCaOUHRC+qJDRX06O/1CjVbZGU0yU8N2XncwPvv5F8uWnyqZ41SSlmFcrB0/37eVDaNE4PQeuh8ric5GAk= 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: 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.