From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f51.google.com (mail-yx1-f51.google.com [74.125.224.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD02419E97B for ; Sun, 30 Nov 2025 18:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764526611; cv=none; b=k6yQN70yE04FCkJ4M4sOYweNzWVyeEBFRoDeghKsuWh9q9nvZ/AhG/hPyYNeU8jqeAFZEu7czSPLI2VtLeBq1r5sxQn4hx8ecX8GQ4yP++xmzJDNXx8sep0NHXA8CZxyRFAOKBctmAaJmfP4E2LDHeSdQVwSEOgJqLmX3Zt1ujg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764526611; c=relaxed/simple; bh=KvguCsz4pFutF0DfQ4yn73w4b9PB3j46YC5jFCOIPbI=; h=Date:From:To:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=fNNW0W5HqbneIgrWc/AqGXuihQuGIb5fcCleJvolf4NBO/JR+ZIragiXV+Ugno/Pqrsano+2yc2gko8MVoofQXieygKAW6zOOwq4VHbWN5LnLVnCfsogNv8qQN44geE2rZR6xPkv8GB+RtrZ2fH9sV1y+3O9maRXzKltaixAgYU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KkkABKgO; arc=none smtp.client-ip=74.125.224.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KkkABKgO" Received: by mail-yx1-f51.google.com with SMTP id 956f58d0204a3-640d0895d7cso4299469d50.1 for ; Sun, 30 Nov 2025 10:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764526608; x=1765131408; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=JyAdI2hiDQd5HiIOsukC026FiEA0dW/JcjYmFaMww+Q=; b=KkkABKgO3i88qTaPEM8l4qF0qVQb2Oc83BM9rlYPGe6aEwWoQk123eSP/qOL5VkvoT E4dmxtIWk/0xbe+d+bzyYeGwnhpcpHZsoEGPmH5hySMmmJzY2Bgnp7D7BRW5mClEBjOT sRLDyOA0f+VmAPmyWKsCLRMXNOvjWG00sZIJHX5/XTu1EfDgvx7CbpXsOsHXUdu83Zaq bdwvnjyz9ZW6ZBEg6GC3ThYkdExYlDGb4aqnNL8olod4IdW8CDxGT+0eMdzGBduAvJMN 1dlUee4gJ7YdZ9jtpFDb/pxtjAaQIO+Z27wL4RZSrsedGsly/OeAqaR0cKNjMQ+qVfL0 Jw9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764526608; x=1765131408; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JyAdI2hiDQd5HiIOsukC026FiEA0dW/JcjYmFaMww+Q=; b=lvGSjb25IMp4BCTOCUQG2D2qH96AIqElNpuR0Xk7WCyKymJu3zqvyaUpjnFaTX1XAh KIlCuNYSq6hjN46oOX6kybUXtV/N6xIenAEr0ebZCPcDsCpKo0qoXDqrmKBjLLqgRG+0 ooGkDmoA4AkS7Hj/DEMx5425xgDypeCGA0wpD/fhrYt/vMShdjjGjC7C56MA18eGZwNh ngZAtXYC6Pj6v3+0nzgKuB4+xRxaZOghBZiOTN4tZ+wifygZByD4usKDe22Vz2DsxoGS izQGqJ9qVLqj2w5ke4gHgwk7NBgAI50PwhXyIneSEGQjOz7UirrlUCLAmCh/Ns0ou88M XcDQ== X-Forwarded-Encrypted: i=1; AJvYcCWLfTY3uT4H4T3ZGJjbnrspIydsTD8AE0/ODskSmKhr2bZg/AmRfeUgxtZy4Llv/Lou6dENTO6BcxARPD0=@vger.kernel.org X-Gm-Message-State: AOJu0YxOUWJc4c4LX99h2jhkDV9k86rkSPChE6gr4ZDkpva64NOHv2hU ZQSNQcyCz6y3nPR6U863Nyjvwvl88lFl8q3pnPGatlWiLMY0HM3lWceD X-Gm-Gg: ASbGncsRywSw4OQyTqUxuqxVVWMU3FwDZwC9w1TlK6TVOjqODCZzzBQb3WYngOsaPbn w6G8rud5Hh5/fsl1NHZpyXTAgDnt12AWg6TLeMOvSUGkX6zC0w8qioAjKLC0+qiSAZ/Ugxqrwy0 EpA1OFa5lJrTqoPl2cdjFPGG+XlcdrJwmadYSxL0gRb71w5NdUBi5OZQB2odde+spHz+diaYq48 8ZwyiFF18g+dPoCHWJuyEfBPdnqLItH2zzO2IwD+YNNDKqmMaxp3AOKgEghtmqcbDwKWnTQ2tZW DNcV+WJzEHhnfFYGUxKARGDwyp+N3WK4LOwvESdGCn3/4UYordEh8qCipEBMsmNg7wA7Y9ivEgn Wp21+jZ6YuicHmDmghP3kU9inNJvCNBthONvLmtRE5274xNgxhjaFvdXiSALxhwufStZr3hFdcg sv1aL4SdluUmdegG5cXWAHcmS5j3MUfs7Ac0d7dB+mSDqHttlbuIFkeQxvYn7H6Uo2VVY= X-Google-Smtp-Source: AGHT+IGjUNSaNMlSY1qlNbQudRZSgfRbmbbf/B0rphetUkGqwnK/CkPwKVh/ASYpHjSaXoMyaE9Zng== X-Received: by 2002:a05:690e:1489:b0:63f:b1fd:3850 with SMTP id 956f58d0204a3-64302631797mr26472073d50.33.1764526607842; Sun, 30 Nov 2025 10:16:47 -0800 (PST) Received: from gmail.com (116.235.236.35.bc.googleusercontent.com. [35.236.235.116]) by smtp.gmail.com with UTF8SMTPSA id 00721157ae682-78ad1045723sm39215937b3.55.2025.11.30.10.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 10:16:47 -0800 (PST) Date: Sun, 30 Nov 2025 13:16:46 -0500 From: Willem de Bruijn To: Simon Schippers , willemdebruijn.kernel@gmail.com, jasowang@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mst@redhat.com, eperezma@redhat.com, jon@nutanix.com, tim.gebauer@tu-dortmund.de, simon.schippers@tu-dortmund.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev Message-ID: In-Reply-To: <20251120152914.1127975-3-simon.schippers@tu-dortmund.de> References: <20251120152914.1127975-1-simon.schippers@tu-dortmund.de> <20251120152914.1127975-3-simon.schippers@tu-dortmund.de> Subject: Re: [PATCH net-next v6 2/8] ptr_ring: add helper to check if consume created space Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Simon Schippers wrote: > Add __ptr_ring_consume_created_space() to check whether the previous > __ptr_ring_consume() call successfully consumed an element and created > space in the ring buffer. This enables callers to conditionally notify > producers when space becomes available. > > The function is only valid immediately after a single consume operation > and should not be used after calling __ptr_ring_consume_batched(). Please explain why it is only valid in that case. > Co-developed-by: Tim Gebauer > Signed-off-by: Tim Gebauer > Co-developed by: Jon Kohler > Signed-off-by: Jon Kohler > Signed-off-by: Simon Schippers > --- > include/linux/ptr_ring.h | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h > index da141cc8b075..76d6840b45a3 100644 > --- a/include/linux/ptr_ring.h > +++ b/include/linux/ptr_ring.h > @@ -453,6 +453,23 @@ static inline int ptr_ring_consume_batched_bh(struct ptr_ring *r, > return ret; > } > > +/* > + * Check if the previous consume operation created space > + * > + * Returns true if the last call to __ptr_ring_consume() has created > + * space in the ring buffer (i.e., an element was consumed). > + * > + * Note: This function is only valid immediately after a single call to > + * __ptr_ring_consume(). If multiple calls to ptr_ring_consume*() have > + * been made, this check must be performed after each call individually. > + * Likewise, do not use this function after calling > + * __ptr_ring_consume_batched(). > + */ > +static inline bool __ptr_ring_consume_created_space(struct ptr_ring *r) > +{ > + return r->consumer_tail >= r->consumer_head; > +} > + > /* Cast to structure type and call a function without discarding from FIFO. > * Function must return a value. > * Callers must take consumer_lock. > -- > 2.43.0 >