๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #345

Re: [PATCH net v2 1/2] ptp: drain virtual clock sysfs operations before unregistering children

#345
From: netdev-bot+sashiko
Date: Wed, 07 Oct 2026 21:47
69 lines
8124 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message gives the wrong reason for the
  is_virtual_clock guard in ptp_vclock_remove_sysfs()โ€ฆ

--

ptp: drain virtual clock sysfs operations before unregistering children

This commit removes the n_vclocks sysfs attribute at the start of
ptp_clock_unregister(), before the virtual clock children are walked. Doing
so blocks new n_vclocks stores and drains any that are already running, so a
concurrent store can no longer unregister the same child a second time.
Virtual clocks skip the removal through an is_virtual_clock check.

> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
> index dc398c6b75284..53388b1231980 100644
> --- a/drivers/ptp/ptp_sysfs.c
> +++ b/drivers/ptp/ptp_sysfs.c
> @@ -263,6 +263,12 @@ static ssize_t n_vclocks_store(struct device *dev,
>  }
>  static DEVICE_ATTR_RW(n_vclocks);
>  
> +void ptp_vclock_remove_sysfs(struct ptp_clock *ptp)
> +{
> +	if (!ptp->is_virtual_clock)
> +		device_remove_file(&ptp->dev, &dev_attr_n_vclocks);
> +}

[Severity: Low]
This isn't a bug, but the commit message gives what looks like the wrong
reason for this guard:

  Virtual clocks have no such attribute and must not remove the parent
  attribute when being deleted by its active store.

When a vclock is deleted from the parent's active store, the path is:

n_vclocks_store()->unregister_vclock()->ptp_vclock_unregister()->
  ptp_clock_unregister(vclock->clock)->ptp_vclock_remove_sysfs()

Here ptp->dev is the virtual clock's own device, not the parent's.
device_remove_file() only acts on that device's directory. It cannot reach
the parent's n_vclocks attribute.

ptp_is_attribute_visible() also never creates the attribute for virtual
clocks:

	} else if (attr == &dev_attr_n_vclocks.attr ||
		   attr == &dev_attr_max_vclocks.attr) {
		if (ptp->is_virtual_clock)
			mode = 0;

Without the guard, device_remove_file() would just find nothing and
kernfs_remove_by_name_ns() would return -ENOENT. There is no self-drain of
the parent's attribute for the guard to prevent.

Could the commit message say instead that the guard only skips a no-op
removal on virtual clocks, which never have n_vclocks? As written, it
reads as though the guard is what stops the parent's active store from
draining itself.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261005-ptp-vclock-sampling-v2-0-8ed12d4d10af%40gmail.com
Technical Details
Message-ID: <179140967248.434549.15357420235192842364@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342553-linux-kernel-netdev=dewy.ru
References: <20261005-ptp-vclock-sampling-v2-1-8ed12d4d10af@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342553-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 1/2] ptp: drain virtual clock sysfs operations
 before unregistering children
Date: Wed, 07 Oct 2026 21:47:52 +0000
Organization: Usenet Network
Message-ID: <179140967248.434549.15357420235192842364@kernel.org>
References: <20261005-ptp-vclock-sampling-v2-1-8ed12d4d10af@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="745306"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:k/59xE/5sm8CalVKnXqFMq+WaDg= sha256:4vw0gplzfQhUGTJyr5bNd1xQHGVBhYNx2IFCP0+31Yg=
	sha1:nAsn4fgjaU1/NmD8T7YU96fUOeo= sha256:7zt8IWRi7gvcl2zcMV2w9gKdQud3+bM0edlNW4gdURQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4261110F254; Thu,  8 Oct 2026 00:48:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.34
X-Spam-Status: No, score=-1.34 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Xk4pXif_1zD3;
	Thu,  8 Oct 2026 00:48:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-342553-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 2CD6F10F04A; Thu,  8 Oct 2026 00:47:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id C6F682E5EC; Wed,  7 Oct 2026 21:47:55 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D75F3815F3;
	Wed,  7 Oct 2026 21:47:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f0zFdIRi"
X-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 EEA5F27E1DC;
	Wed,  7 Oct 2026 21:47:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791409674; cv=none; b=itDpNNi78utcstZzRHyjkjJlRwhPKUAhNug6/10tPOGdCjsJGmj+9I4rNWfzJhokJOXov9TqwRQ5hcxHFhM00syXn52BivdS0ArDlRUlDDxoMhAQLTMHN2RA9QPZrECOT/lz0rjL7YazOjJqPEKX6l8MUQKSbfFn8qUY5HhidoA=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791409674; c=relaxed/simple;
	bh=iCuEgTy3fWk8SL88SbuVaHRBc8KZTRoMUnGDJiOoXMM=;
	h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References:
	 Content-Type:MIME-Version; b=VUv3yIqZGPOtZvOvaj0LOGOdl3LZEivqS2jJvPRMLbpjDQdJyjkR9jWV1hE16N0Xo56uoQuWzAQCpggJndyN9tgr0mTvcXnw+XBaPHIMMlABNR45cuMo09OLzJKd8x9FZwqqtuHQ6zzt+9h5zB1ha7eDg/7QNQLupomvAdBE40E=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f0zFdIRi; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F08F51F000FF;
	Wed,  7 Oct 2026 21:47:52 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1791409673;
	bh=ZZLzBrm9AgpobsusQS1OCG+MADJektCGs465QeVYBJk=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=f0zFdIRinkfZRcKlHGvTCQ24VejwnRSrAPssUQij3ZaEtVV9hF57pF0C1BOYlOD9C
	 Poh7UJ5X8OgR7l6/ujHwqBMQSeUwlEW2yieO51cfYFy21lu8UIYPvYsvyHJHri7lSL
	 NnmgxDw7eBM9PwX1pu0ARYqaKeJq2UpDBAtn5f+E8DMkRY5SX6BFFQJhemPhA0hZU7
	 8dapqwbcl1fZ4U9RYPfNEE4Yf2J5v2pIMneMOuV5rlBUW4rHn4hd645v3XXzjzdESa
	 YWtq4z9a9UhVwrszEzX7atU+LcVa3ZIy1mCffnIH/nmEFirSp2U4Z1CP+1JEAAiXZw
	 ruq17fWQVZ9AA==
X-Cc: netdev@vger.kernel.org, pabeni@redhat.com, kuba@kernel.org,
 richardcochran@gmail.com, andrew+netdev@lunn.ch, yangbo.lu@nxp.com,
 edumazet@kernel.org, davem@davemloft.net, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261005-ptp-vclock-sampling-v2-1-8ed12d4d10af@gmail.com>
X-sashiko-severity: Low
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>