From nobody Wed May 1 11:14:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1643265041; cv=none; d=zohomail.com; s=zohoarc; b=AO29BuM2J3q/gynO+bLEuuI0yWIgjOVtXrJqxq5jH111unXvjJ0w08xPE2LND52kszXL3jS1ch5mEqEYxd/aPxbnd9p4g0hE1dXdIRWX1IyoOUcBx08R4wt0i3lPRt9kCgOneHNsNPyJcwI9RQWs2PPmdg4/DdM3xblhhStTS+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643265041; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=BUVsitANnbfJYDv58OBHl6jlg+ZcSi87+nae04lEbFE=; b=PAGwb0LYzt9EBLcO1zDYQv/NYuRZkLQdqJmO22cL2Ybb0lyhTUcWHSRFFlj6lmC4EA7U5NSZkHUa93Qpi4Ivw5Y5fnZlzT5YbToYobap96NeY+QktWpRpYIXbqRmuv8sBrFI2l9JokozIGV076SMpBrc+YNMEw7gAZ+/8+jQM3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1643265038782186.6760106844364; Wed, 26 Jan 2022 22:30:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.261192.451973 (Exim 4.92) (envelope-from ) id 1nCyIP-00070T-0x; Thu, 27 Jan 2022 06:30:13 +0000 Received: by outflank-mailman (output) from mailman id 261192.451973; Thu, 27 Jan 2022 06:30:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCyIO-00070M-U7; Thu, 27 Jan 2022 06:30:12 +0000 Received: by outflank-mailman (input) for mailman id 261192; Thu, 27 Jan 2022 06:30:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCyIN-00070E-0n for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 06:30:11 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 92cd8cb4-7f3a-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 07:30:09 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9D2041F3AF; Thu, 27 Jan 2022 06:30:08 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5EA8413470; Thu, 27 Jan 2022 06:30:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sJ7dFfA78mH8cgAAMHmgww (envelope-from ); Thu, 27 Jan 2022 06:30:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 92cd8cb4-7f3a-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643265008; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BUVsitANnbfJYDv58OBHl6jlg+ZcSi87+nae04lEbFE=; b=n25Q8+kwBUoLwO3tKZkEk4VLT1bsb4RxhJd87/iQ9blc+X1213uRcZNRWVA2tb6O+uw6c1 WR0WqibiCci2usTsz4OxzjpUcCMmroR09FZSiGEAAfvYPs3w+9n99eaVfy0yi8xTUDhA9b qIkF/ki/2HsORhw0QKrHvRRGgAtj7wc= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Roger Pau Monne , Manuel Bouyer , Simon Kuenzer , Paul Durrant Subject: [PATCH v3] public: add XEN_RING_NR_UNCONSUMED_*() macros to ring.h Date: Thu, 27 Jan 2022 07:30:04 +0100 Message-Id: <20220127063004.7937-1-jgross@suse.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1643265044889100001 Content-Type: text/plain; charset="utf-8" Today RING_HAS_UNCONSUMED_*() macros are returning the number of unconsumed requests or responses instead of a boolean as the name of the macros would imply. As this "feature" is already being used, rename the macros to XEN_RING_NR_UNCONSUMED_*() and define the RING_HAS_UNCONSUMED_*() macros by using the new XEN_RING_NR_UNCONSUMED_*() macros. In order to avoid future misuse let RING_HAS_UNCONSUMED_*() optionally really return a boolean (can be activated by defining XEN_RING_HAS_UNCONSUMED_IS_BOOL). Note that the known misuses need to be switched to the new XEN_RING_NR_UNCONSUMED_*() macros when using the RING_HAS_UNCONSUMED_*() variants returning a boolean value. Cc: Roger Pau Monne Cc: Manuel Bouyer Cc: Simon Kuenzer Cc: Paul Durrant Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V3: - add XEN_ prefix to new macros (Jan Beulich) --- xen/include/public/io/ring.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h index c486c457e0..277af36e61 100644 --- a/xen/include/public/io/ring.h +++ b/xen/include/public/io/ring.h @@ -208,11 +208,11 @@ typedef struct __name##_back_ring __name##_back_ring_t (RING_FREE_REQUESTS(_r) =3D=3D 0) =20 /* Test if there are outstanding messages to be processed on a ring. */ -#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ +#define XEN_RING_NR_UNCONSUMED_RESPONSES(_r) \ ((_r)->sring->rsp_prod - (_r)->rsp_cons) =20 #ifdef __GNUC__ -#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \ +#define XEN_RING_NR_UNCONSUMED_REQUESTS(_r) ({ \ unsigned int req =3D (_r)->sring->req_prod - (_r)->req_cons; \ unsigned int rsp =3D RING_SIZE(_r) - \ ((_r)->req_cons - (_r)->rsp_prod_pvt); \ @@ -220,13 +220,27 @@ typedef struct __name##_back_ring __name##_back_ring_t }) #else /* Same as above, but without the nice GCC ({ ... }) syntax. */ -#define RING_HAS_UNCONSUMED_REQUESTS(_r) \ +#define XEN_RING_NR_UNCONSUMED_REQUESTS(_r) \ ((((_r)->sring->req_prod - (_r)->req_cons) < \ (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \ ((_r)->sring->req_prod - (_r)->req_cons) : \ (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) #endif =20 +#ifdef XEN_RING_HAS_UNCONSUMED_IS_BOOL +/* + * These variants should only be used in case no caller is abusing them for + * obtaining the number of unconsumed responses/requests. + */ +#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ + (!!XEN_RING_NR_UNCONSUMED_RESPONSES(_r)) +#define RING_HAS_UNCONSUMED_REQUESTS(_r) \ + (!!XEN_RING_NR_UNCONSUMED_REQUESTS(_r)) +#else +#define RING_HAS_UNCONSUMED_RESPONSES(_r) XEN_RING_NR_UNCONSUMED_RESPONSES= (_r) +#define RING_HAS_UNCONSUMED_REQUESTS(_r) XEN_RING_NR_UNCONSUMED_REQUESTS(= _r) +#endif + /* Direct access to individual ring elements, by index. */ #define RING_GET_REQUEST(_r, _idx) \ (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) --=20 2.31.1