From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-m49244.qiye.163.com (mail-m49244.qiye.163.com [45.254.49.244]) (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 C100D414DC1 for ; Tue, 7 Jul 2026 13:19:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.244 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783430344; cv=none; b=ryFb31/861+NtyKuWIV6hxLGo0+vKHwO5+G2HGP9MkoBkEOotx5EjVV5Q1ht6slOhk3YykIkH0tP+HadzVKZt/t5hZC30IbaLspASz4e2EaQmZUjbZPNqm4E+v8fp0O12sAV4QBn8vfcxNU1DRWhUSwaHnEJRTUx7zFmMB9TH7s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783430344; c=relaxed/simple; bh=jL53LjxdSqRNtkPMwSHPMSYI0/TszsQZPjoaMJ6jHWY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cl8H9yz9gTfNk8LBTZjL3kDIIYgujXLgYyJqTr42dvNd9HkeeLvOurHLIAQa+fghk+6UdSuXcWfUIYhQusd3+sBLGnaAWbpPrnmE7PiiI0jeOdm9XB6H9N0T+JukBIZsHXJIPywpvbXr/x3PH2H9s/7qnKzNql4/PLtMEMLIu8w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn; spf=pass smtp.mailfrom=easystack.cn; arc=none smtp.client-ip=45.254.49.244 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=easystack.cn Received: from [192.168.0.59] (unknown [218.94.118.90]) by smtp.qiye.163.com (Hmail) with ESMTP id 1c625bf4d; Tue, 7 Jul 2026 14:29:11 +0800 (GMT+08:00) Message-ID: Date: Tue, 7 Jul 2026 14:29:11 +0800 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 To: "Vlastimil Babka (SUSE)" , 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> <16e9bcf6-3e7d-44e9-8b07-00a694c8e493@kernel.org> From: "zhen.ni" In-Reply-To: <16e9bcf6-3e7d-44e9-8b07-00a694c8e493@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-HM-Tid: 0a9f3b442e1c0229kunmab920514456ba X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWRgWCB1ZQUpXWS1ZQUlXWQ8JGhUIEh9ZQVkaGEgdVh5KSEIaSx4fHkNLSFYVFA kWGhdVGRETFhoSFyQUDg9ZV1kYEgtZQVlJSkNVQk9VSkpDVUJLWVdZFhoPEhUdFFlBWU9LSFVCQk lOS1VKS0tVSkJLQlkG 在 2026/7/3 16:51, Vlastimil Babka (SUSE) 写道: > 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 > > > I'll remove the spinlock in v12 soon. Thanks, Zhen