From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 151A937CD32 for ; Fri, 3 Jul 2026 08:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783068681; cv=none; b=Jdqpbjw81Q9Xz+tXcqmMGIMm1Nqrn4ShmkqXeEu5P/HRcDDbnS9RcM4HRp4M+6fuF6/wloCMppF6SJ7CGOC8NSy2NaTDfW7fnwO6KcAkVNs3uB8maBBS3TeoUAQwn9VBjtu8qaJpEJ2lZ4HMTEe81SDH/qzuCHmp6JByntxnNAk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783068681; c=relaxed/simple; bh=PU0wSn8TguVWQpiSAm3/q6QwJ2Wz73IPcpvJz9e7XF8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UsL5KEwz6esMQm/0IoLiD/7sO0bQzJ1SgvDMlw5gKfvT/cOlfXM64QjK2f971l4/iX3NzBAMfApYi/PRkSybZUZyO2US9jm5xA7QaLzvifJJqLb9r6ZiqytGTAxhHj9OpGPyIYWBRlIoiRlhrwBFT436fuNzPPWYCSVx69zQjFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QcYMbdgF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QcYMbdgF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B69061F000E9; Fri, 3 Jul 2026 08:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783068679; bh=bJAwgSZ9N+lWhcSTPqdOjsrWX1mZ+mtkHDlETjGI0qw=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=QcYMbdgF6Mz5fC/5+OIcISEIML/hLi20/XfclgLIvxREhH1W52SIRO0kfNwWvcVcu 9b07HTep+Jt9Jzxft+/qdGiBxxRwaH7fxeIKfBIprufCOqtU2v7hIA4OtdQcJ7hL8p rqoijW2f+Nm8yBUlaWetRvwJ1/AQd3k88NnoNn+Z9GfzXoClvA9z8+yK1Gn0QRRq1Z dH/HyhrErjcCagjCJaTUvvKwRzbGZFSNMqIytlsF/ldBdF26D2oeObDcLObicnhmrS MuQF4jh3x4gjHFdx13S42I0loT5s0U95oHmEPnAr4uTHhiJbEVwuu/7pGmlNL9cNAm IJsI5HNzZuDug== Message-ID: <16e9bcf6-3e7d-44e9-8b07-00a694c8e493@kernel.org> Date: Fri, 3 Jul 2026 10:51:16 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 1/4] mm/page_owner: add print_mode filter Content-Language: en-US To: "zhen.ni" , Ye Liu , akpm@linux-foundation.org Cc: surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20260625043101.338794-1-zhen.ni@easystack.cn> <20260625043101.338794-2-zhen.ni@easystack.cn> <49526116-ce35-4447-bd98-f5f0ca12d92a@kernel.org> From: "Vlastimil Babka (SUSE)" Autocrypt: addr=vbabka@kernel.org; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2q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8OdU/+V+R3O4 0PXWvX8qrvqYapVbZ+9KqT74FsuB0Ya9uXwgBF2Q6cRuETZk5vqaqKxzqoQZCO8AOz/58j6O 2RHNy/mZEN+7tJ5Tsq42zVJ4jxsT8b9YplavCMsnBgDeRWhcbYhCyttoL7nYISyWg4kQYZ/P wIV3OuNv2f8iKYsxNsRuClOAF82+gvqOy1/1pprFjy8uo2pkoOrb63aOP3vO5VHnRKgra6dq NcaZ+c6J4H+nEJGi2SkHAUJz5oBzuThvPudLvPA/SK8sKoM01IRxSihev/S/5WLazXB1PGem OCbvzC1IjWJJraxiDJ5IygokapUa2RP7+WBR22skQ3SSl6G107QgWKSyTOGWEaRmV53vxQLV jXuCmzSSasTL60zq5yGrT4/DYQVSNEUiUbG4pYekxJujNeEDkUlky0Y= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 7/3/26 10:14, zhen.ni wrote: > > > 在 2026/6/29 17:30, Vlastimil Babka (SUSE) 写道: >> On 6/29/26 04:59, Ye Liu wrote: >>> >>> 在 2026/6/25 12:30, Zhen Ni 写道: >>> Hi , Zhen >>> The spinlock in struct page_owner_filter_state is unnecessary and adds significant overhead in the read path. >>> >>> 1. Per-fd isolation: the state is allocated per open() and stored in file->private_data. >>> There is no cross-fd contention possible. >>> 2. Hot path cost: the lock is taken for every single page in read_page_owner() and >>> print_page_owner(). A single read can traverse millions of pages, each paying >>> spin_lock_irqsave/irqrestore — including interrupt disable — just to read a mode >>> enum or check a nodemask. This is measurable overhead for no real benefit. >>> 3. No practical race: nobody writes filter config to an fd while simultaneously reading from it. >>> >>> Suggest dropping the lock entirely. >>> >>> Just my take though — happy to follow whatever the other reviewers prefer here. >> >> I agree. If someone is writing (updating filter) and reading (getting >> page_owner output) at the same time from multiple threads, they might get >> inconsistent results but that's getting what you ask for. Importantly it >> can't cause any crash, AFAICS. >> >> > > Hi Vlastimil, Ye, > > Thanks for the review. I understand your concerns about the spinlock > overhead in the read path. > > The spinlock does have its use case: it prevents race conditions when > multiple threads share the same file descriptor and call read() and > write() concurrently. While we recommend users use the page_owner_filter > tool, we cannot exclude the possibility that some users might directly > share the fd across threads. Yeah and they will then get inconsistent results even with the spinlock, we don't have to prevent that. > That said, I'm open to discussion on whether we need the spinlock. As > Vlastimil noted, the issue isn't severe enough to cause crashes. My v8 > version didn't have the spinlock - I added it in response to review > feedback. It was in response to sashiko. Those suggestions are sometimes useful, sometimes not. It's good to consider them, but critically, and not implement blindly. > So the question is really whether we want to protect multi-threaded fd We don't. > sharing or not. Because, the overhead is small in non-contended cases > (single-threaded usage) since there are no competing lock holders. The atomic operations are still expensive and unnecessary. Thanks. > Thanks, > Zhen