From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 8B9A631A7F2 for ; Tue, 3 Feb 2026 12:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770122582; cv=none; b=OfpNP0X7l5lSFcmu6Q6p+H6J8sFjd8H9kE9nwTLzoABV5WbAnJAxeup4y4KvThbBNXni/gch4QUlbQwWGY3G+BSymyJ4s8R5nxqzaxIlx76p6c6OkG55NFr9b/m9GQ2dtngOPL0LOHUNnADHrf+tGeB2FmRmcUhGI0B/dVZni7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770122582; c=relaxed/simple; bh=u+chm2qe2UaDCOdZTAISqPdNE1lhHXCRqAvQjvQx0WM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Rd7EOdKIubDs9rvL23dCeIt0PfKihhLc/G5YwQ4FOBazif1UKiszWkluGxyqo/hjpDXXanp1eHcqII7tZPWozbbkf8/FW2UFRY2+AkDUTMqe/GGxM4kWZo7PkU7NcaUa59dNc9Am3Ym9K4UU1i17KiB86+nAbOPNqBD5C5Asc+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CEvxVeql; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CEvxVeql" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770122580; 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=LF3GRiApzlM2RrKH+kiOvRs8f6wdo1Fn0YQ6vnScJiQ=; b=CEvxVeqlZeITVeE6vpHS31bB+Pk4DlUGinUoLd8u2dVfAr0fOU7NeGTNtN+HT0HsoeB0gC RTXmMFu7OFM0fgrNgsuQ7ePmAMbGkFTcdhtKlNK6Ki8egqwBe+h8jcu9Vwb97b1IcNWCk6 7cED9UdYscr2ZPfBSbT+a3jZ2SIKZGo= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-moibDoRpM9-yTHg7ZbNy_Q-1; Tue, 03 Feb 2026 07:42:57 -0500 X-MC-Unique: moibDoRpM9-yTHg7ZbNy_Q-1 X-Mimecast-MFC-AGG-ID: moibDoRpM9-yTHg7ZbNy_Q_1770122575 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3E2EC1800365; Tue, 3 Feb 2026 12:42:55 +0000 (UTC) Received: from thinkpad (unknown [10.44.34.184]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6A6E7180176D; Tue, 3 Feb 2026 12:42:51 +0000 (UTC) Date: Tue, 3 Feb 2026 13:42:48 +0100 From: Felix Maurer To: Sebastian Andrzej Siewior Cc: Simon Horman , netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jkarrenpalo@gmail.com, tglx@linutronix.de, mingo@kernel.org, allison.henderson@oracle.com, petrm@nvidia.com, antonio@openvpn.net, Steffen Lindner Subject: Re: [PATCH net-next v2 4/9] hsr: Implement more robust duplicate discard for PRP Message-ID: References: <20260128163824.GB172540@kernel.org> <20260202165702.R9PI3JSM@linutronix.de> <20260203115719.cU_6tnal@linutronix.de> 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: <20260203115719.cU_6tnal@linutronix.de> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 On Tue, Feb 03, 2026 at 12:57:19PM +0100, Sebastian Andrzej Siewior wrote: > On 2026-02-03 11:23:57 [+0100], Felix Maurer wrote: > > On Mon, Feb 02, 2026 at 05:57:02PM +0100, Sebastian Andrzej Siewior wrote: > > > On 2026-01-28 19:37:23 [+0100], Felix Maurer wrote: > > > > > > + if (!block) { > > > > > > + block = &node->block_buf[node->next_block]; > > > > > > + hsr_forget_seq_block(node, block); > > > > > > + > > > > > > + memset(block, 0, sizeof(*block)); > > > > > > + block->time = jiffies; > > > > > > + block->block_idx = block_idx; > > > > > > + > > > > > > + res = xa_store(&node->seq_blocks, block_idx, block, GFP_ATOMIC); > > > > > > + if (xa_is_err(res)) > > > > > > > > > > Hi Felix, > > > > > > > > > > I ran Claude Code over this with review-prompts [1] and it flags > > > > > that in the error path above, the following is needed so that the > > > > > block can be re-used. > > > > > > > > > > block->time = 0; > > > > > > > > I agree. It would nonetheless be reused at some point, but not setting > > > > time = 0 may lead to an unexpected block getting removed when it is > > > > reused (or at least an attempt to do so). I'll fix this in v3. > > > > > > Not sure I follow. If xa_store() fails then the block is not added to > > > the "sequence-blocks" and it will be attempted once the next packet is > > > received, right?. Otherwise node->next_block is not updated at which > > > point this block will be added twice which sounds worse. > > > > Yes, it will be attempted again on the next frame that needs a new > > block. But every attempt to recycle the next_block starts with calling > > hsr_forget_seq_block(), which tries to xa_erase() the block if time!=0. > > Generally, time==0 is the marker that a block is not stored in the > > xarray. So for consistency it's correct to set time=0 if the block can't > > be added to the xarray, even though I don't think it would cause any > > trouble at the moment if the time is not reset. > > My point is that the block will not be recycled if it failed to be added > here. It remains the "next" block to be used and added to the list if it > fails that xa_store(). Hm, I'm not sure I follow. Do you argue that the code already in the patch is incorrect or that it would be incorrect with Simon's suggestion? Yes, in case the xa_store() fails, the current "next" block remains the "next" block. But we also definitely erased it from the xarray already. With the next frame, we attempt to recycle/insert the block again. I don't think that can lead to the same block being used twice? I understood Simon's suggestion this way: in the error path, *also* reset block->time to 0. We'd still return NULL in that case and, crucially, don't advance the next_block. IMHO, that only makes the data more consistent (blocks in the buffer that are not in the xarray always have time=0) and prevents that we try to remove a non-existing entry from the xarray on the next frame when we try again to recycle the current "next" block. Thanks, Felix