From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) (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 0319637DEBC for ; Tue, 3 Mar 2026 04:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772510503; cv=none; b=J9L6VZ2xfGlUfn+mNOX03D5KCE4VgXDkkGrraHWN0/i7wy9rmPNjL7M3Tj8j8Qi7rVdncac6vXHTDIyW/aua0e0tlphbQpbD177GHD2+fMO9mYNiRAGKwZaWOaG56wYjoihl4ZnOAluiYRVfK3nJ6oclsakSb46M9OWo+OSacWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772510503; c=relaxed/simple; bh=ihWsTEcR5FoPq30WiXprE/Wlo0jqWSzXKrxrzmLJ8gk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eo1AUtjTK6ohUh5Yg/X3EI53KKMRniV8Dm1O3cyLTY1AJZ7a9MgAT3PgXcAgTS0FAabfY69Rjbs0CtGmCOS2LI+G/O2hfYjTkeaGOa3+y4dq/vdfORMYqPCKzhxClIYvip9FS3XE3CXYCXT9QeohFPOTP441uPanleX8PJ2y3nk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=RyIuvuDu; arc=none smtp.client-ip=95.215.58.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="RyIuvuDu" Date: Mon, 2 Mar 2026 20:01:24 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772510491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hBGmF2s+SBlpG4pIc5F6jycqjWcB52xkmfpfhl7IPaY=; b=RyIuvuDuMThd4LbXF0ndsQw3dQna3mugcwnPflVjtV8ftPXbFGG/ezqLhplhFvmjA1yW3d Vbx9Xx1uEQe1PUFvClc1YAfep/On97EoSQifdLMkD7n2d1S0VoAQfDTVt42FoDG18QjGLD BcCzOPQP/oFzL8rhEN0Y04McZ7hFA4Q= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Chen Ridong Cc: Tejun Heo , Johannes Weiner , Michal =?utf-8?Q?Koutn=C3=BD?= , Roman Gushchin , Kuniyuki Iwashima , Daniel Sedlak , Meta kernel team , linux-mm@kvack.org, netdev@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski Subject: Re: [PATCH 2/3] cgroup: add lockless fast-path checks to cgroup_file_notify() Message-ID: References: <20260228142018.3178529-1-shakeel.butt@linux.dev> <20260228142018.3178529-3-shakeel.butt@linux.dev> <40c77bba-0862-4422-b23e-2a10cd01c728@huaweicloud.com> <372e0d67-ab3f-427f-970d-5d1c7cb68c92@huaweicloud.com> Precedence: bulk X-Mailing-List: netdev@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: <372e0d67-ab3f-427f-970d-5d1c7cb68c92@huaweicloud.com> X-Migadu-Flow: FLOW_OUT On Tue, Mar 03, 2026 at 11:18:17AM +0800, Chen Ridong wrote: > > [...] > > @@ -4689,6 +4689,12 @@ void cgroup_file_notify(struct cgroup_file *cfile) > > unsigned long flags; > > struct kernfs_node *kn = NULL; > > > > + if (!READ_ONCE(cfile->kn)) > > + return; > > + > > + if (timer_pending(&cfile->notify_timer)) > > + return; > > + > > The added timer_pending() check seems problematic. According to the function's > comment, callers must ensure serialization with other timer operations. Here > we're checking timer_pending() locklessly, which means we might: > That comment seems outdated. Check the commit 90c018942c2ba ("timer: Use hlist_unhashed_lockless() in timer_pending()"). > 1. See an inconsistent state if another CPU is concurrently modifying the timer > It will not see inconsistent state but it can see stale state which is totally fine. At worst we will take the lock and recheck but we will never miss the notifications. > 2. Race with del_timer() or mod_timer() from other contexts > > > spin_lock_irqsave(&cgroup_file_kn_lock, flags); > > if (cfile->kn) { > > unsigned long last = cfile->notified_at; > > -- > Best regards, > Ridong >