From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53CECA0540; Tue, 14 Jul 2020 21:50:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6B7DD1D16D; Tue, 14 Jul 2020 21:50:33 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130072.outbound.protection.outlook.com [40.107.13.72]) by dpdk.org (Postfix) with ESMTP id 9BA911D165 for ; Tue, 14 Jul 2020 21:50:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=exwcEGnfgHoafG/PGNsCHf48cFchIvSlrR8sE85Em2A=; b=DwBaR3ekxcmMW056U4EmT8nxvi4t0NIerWEPGogNGLc2ClWwk5uKaU05prGE1if48O4HVxBo8DE5e2Hu4kDE4FmukxGvXsrDUiX6VpHBbrLUlZe0RFiXT3rXq2qK8YKqlPEL0W0pck8x2Fna4godDwSZtZ+5yydaI0L5WVgWFfk= Received: from AM5PR0301CA0036.eurprd03.prod.outlook.com (2603:10a6:206:14::49) by AM6PR08MB5064.eurprd08.prod.outlook.com (2603:10a6:20b:e6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Tue, 14 Jul 2020 19:50:29 +0000 Received: from AM5EUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:14:cafe::c5) by AM5PR0301CA0036.outlook.office365.com (2603:10a6:206:14::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22 via Frontend Transport; Tue, 14 Jul 2020 19:50:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT028.mail.protection.outlook.com (10.152.16.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Tue, 14 Jul 2020 19:50:29 +0000 Received: ("Tessian outbound 8f45de5545d6:v62"); Tue, 14 Jul 2020 19:50:29 +0000 X-CR-MTA-TID: 64aa7808 Received: from c0403be90443.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 13C0AA41-03C6-49D8-9EF7-EF8CA0375356.1; Tue, 14 Jul 2020 19:50:24 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c0403be90443.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 14 Jul 2020 19:50:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cDZrK8qafaMFtgWj681IfBjDpbtWkFGayKxLtMs6ZBbaqJtVioCAQ7lITu32urFqGxkw19q0P1YvRhmyOkvJg+VXUlZ0+AlhdWSuraJeWsjLN3p6mBBJbE9zXCEdc9TOquonMX1swQIUZCxWas3x1vxkYczQC+dx0ukQBxDLrbhi398nHF+m/obnOlo9rm719o3+hTNaywmn/MNQQBZekgE54z3ZOGyMZITqRCyew9GDbxjKoS+ru7FN577Q6hk64nh0NymRK8Jv+JyHNxX/zSVEPrxZaLh0qeJYdzVH6UcA2CcBK9dw7VqWH2EzSmz/FRBuCdhudpNraTJCoC6Log== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=exwcEGnfgHoafG/PGNsCHf48cFchIvSlrR8sE85Em2A=; b=ElKjimaIiIyRH/lWRlYTpA101iD+T5bGH+1B1s7BfaURZmsZRmK2V3LFyBLXRrs27KKDlO7uoaljPbfQSgBddq3HD2e33x8ZpKiMjwyuUnfZ2xBcSrAZyB8AS3MptxDGBRzjdwcAIR3sKdV9U2CDWCJS+D3HCAVv6boQ1I/G9alXVFukwn1oAGCOdWTisgwpcDALbvUdn9iPxjqkIONIVGmfDFqNcLoULrKcVxI42rLgvUccdJ23JJC4W8+nHQBoLwmBTL4qUkZcGigxON062Ldb2tknPtC4XUhcc50LX2Nk+UirhXuU22magAy0LiynbT9y23EMCOH7qeDCZ2G4Dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=exwcEGnfgHoafG/PGNsCHf48cFchIvSlrR8sE85Em2A=; b=DwBaR3ekxcmMW056U4EmT8nxvi4t0NIerWEPGogNGLc2ClWwk5uKaU05prGE1if48O4HVxBo8DE5e2Hu4kDE4FmukxGvXsrDUiX6VpHBbrLUlZe0RFiXT3rXq2qK8YKqlPEL0W0pck8x2Fna4godDwSZtZ+5yydaI0L5WVgWFfk= Received: from DB6PR0802MB2216.eurprd08.prod.outlook.com (2603:10a6:4:85::9) by DB6PR08MB2757.eurprd08.prod.outlook.com (2603:10a6:6:18::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.24; Tue, 14 Jul 2020 19:50:22 +0000 Received: from DB6PR0802MB2216.eurprd08.prod.outlook.com ([fe80::9d1d:207b:e89d:199d]) by DB6PR0802MB2216.eurprd08.prod.outlook.com ([fe80::9d1d:207b:e89d:199d%10]) with mapi id 15.20.3174.026; Tue, 14 Jul 2020 19:50:22 +0000 From: Honnappa Nagarahalli To: Stephen Hemminger , "dev@dpdk.org" CC: nd , Honnappa Nagarahalli , nd Thread-Topic: [dpdk-dev] [PATCH] eal/interrupts: add function to allow interruptible epoll Thread-Index: AQHVQkQnqfjGwdRmfk+RlmYySEUAXakJoM1w Date: Tue, 14 Jul 2020 19:50:22 +0000 Message-ID: References: <20190724172037.7776-1-stephen@networkplumber.org> In-Reply-To: <20190724172037.7776-1-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 14977ba1-c0cb-4c08-99f6-b58e5f803894.0 x-checkrecipientchecked: true Authentication-Results-Original: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=arm.com; x-originating-ip: [70.112.90.121] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 67968c34-fb0f-470c-c4bd-08d8282f2984 x-ms-traffictypediagnostic: DB6PR08MB2757:|AM6PR08MB5064: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:4502;OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: v1p6oewRQ29syVUu1t3EO36tCyLQqVPbrhzNaYDRE4aXfqjivwVqW0WMS1wRXcb0tnKxZ+K2fXntPPWft1KAJmU2FvNzlUFiHo2cZW+XvCakGAbjosdQH6orNR0fakR6uvmXXBDyUk+zT8iCiHum34zVVxT6d4wr1LXjEkJkN6VsoqcOERRn0j3+0GGbzHSyTnf8mLtGVeJT95ONQReK/zeaWo2jQ5HUZeXjdB8/6uYaB+VL2h8HPdrdEMR18l8CQcKxvlLS/brot5f6N1ZySkupoeKyC7Jyz7otfqeqmm8DoWBTuP4pNTdhcEJ/KeEDUpIloctoeFT1rnQ/cd9M/g== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0802MB2216.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(346002)(376002)(136003)(39860400002)(396003)(86362001)(83380400001)(71200400001)(76116006)(66476007)(66946007)(64756008)(66446008)(66556008)(33656002)(186003)(53546011)(7696005)(6506007)(26005)(9686003)(478600001)(8936002)(2906002)(5660300002)(4326008)(52536014)(316002)(55016002)(54906003)(110136005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: RSsKeZHFw+GZMW/rO9klqTm4KMZgrgFUIy6vvmEkjlIOG2n0crWyyZhKFZJWQmfyD4yoyUHFuJWpWebNhwBEH6wErFWVaVDH6Rg8OAqxjbGDOGmxGQz9eWam8iUYGxOBzdbaBYYocPRirYGRtVZjhkrsj0Go1z5Y+ltiRSfYv9p/LGLZZTtC2DUm2nqW9/kjAAsZ4CpQVLWLK+vFIgbCGTMQBTcUnPtoiLg8304/M9UAsQHAB/mHK2mIQaf/L5qzhZvZyiy6xRO2OfCUpd7/E5Bhb6EcybCppQMCd/6ziNFS+IaS66Q1A3M6sUEYo4qaG9zWsX9Naahfb4EOkFB9uv8V+3roJ1SVGXyR3Bq7Y1LnZ9jFmLuA+cQf7pGXjuNt02X98cr4pYOKI6sPP9g8Ts6ZITasuIsnPfLPH96u1iyYsZy4wo93qZf229PePX6hEmaGeyNqhRKQYY9v0q9kHUat0dXbpJk7STkM5guR1DoYWnCoanSPJyZz4FuLLotW Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2757 Original-Authentication-Results: networkplumber.org; dkim=none (message not signed) header.d=none; networkplumber.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT028.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(46966005)(81166007)(4326008)(356005)(110136005)(54906003)(82740400003)(83380400001)(316002)(55016002)(52536014)(36906005)(47076004)(9686003)(5660300002)(82310400002)(336012)(8936002)(2906002)(70586007)(70206006)(7696005)(86362001)(26005)(6506007)(478600001)(53546011)(186003)(33656002); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: f95e74eb-350b-44a5-70ec-08d8282f2527 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XN70nFiZhz99xmssoeKwfXNe6RXZsN8ed2jX2AsroikQSaJrti4SOpedKUjkvB+6bqw5Ww8HhdjlFhluvoETrnLHEa7mbQh/u9hwfbSw6l5Fj2TIFEW/bYklvyTIvBbB56RFNiGKk4bs7FQ1yNF2jh5JTgFaf9B3Iit5TmD236SOj6LPgcBTj1znW7EK8MSbI9QmG2adAdE16QVQMCB0n3W37c3EqUbOYFzYd+W/ElIo46nWHXTrj9KIE7HdTVGtWZLRmts5UtZmetf202HjRFW6RpOIOvbHauEt30gyp2AuGLuZHDmPFSen3nDmL3oyatQgfoGtFhgNZ7wzKKJ8MEWznAPcPUCK0p/DsS0Y/G43L2nopIbwZt81P+kQRxrEbeaExROHcwpfpZpbAnf/fw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2020 19:50:29.7496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67968c34-fb0f-470c-c4bd-08d8282f2984 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5064 Subject: Re: [dpdk-dev] [PATCH] eal/interrupts: add function to allow interruptible epoll X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Stephen, Looks good overall, few nits inline. > -----Original Message----- > From: dev On Behalf Of Stephen Hemminger > Sent: Wednesday, July 24, 2019 12:21 PM > To: dev@dpdk.org > Cc: Stephen Hemminger > Subject: [dpdk-dev] [PATCH] eal/interrupts: add function to allow > interruptible epoll >=20 > The existing definition of rte_epoll_wait retries if interrupted by a sig= nal. > This behavior makes it hard to use rte_epoll_wait for applications that w= ant > to use signals do do things like exit polling loop and shutdown. nit ^^ to >=20 > Since changing existing semantic might break applications, add a new > rte_epoll_wait_interruptible() function that does the same thing as > rte_epoll_wait but will return -1 and errno of EINTR if it receives a sig= nal. >=20 > Signed-off-by: Stephen Hemminger > --- > .../common/include/rte_eal_interrupts.h | 23 +++++++++ > lib/librte_eal/freebsd/eal/eal_interrupts.c | 12 +++++ > lib/librte_eal/linux/eal/eal_interrupts.c | 47 ++++++++++++------- > lib/librte_eal/rte_eal_version.map | 1 + Can you rebase with the master? It will help me apply this cleanly. > 4 files changed, 65 insertions(+), 18 deletions(-) >=20 > diff --git a/lib/librte_eal/common/include/rte_eal_interrupts.h > b/lib/librte_eal/common/include/rte_eal_interrupts.h > index b370c0d26458..ac1c830f37a1 100644 > --- a/lib/librte_eal/common/include/rte_eal_interrupts.h > +++ b/lib/librte_eal/common/include/rte_eal_interrupts.h > @@ -87,6 +87,7 @@ struct rte_intr_handle { >=20 > /** > * It waits for events on the epoll instance. > + * Retries if signal received. > * > * @param epfd > * Epoll instance fd on which the caller wait for events. > @@ -105,6 +106,28 @@ int > rte_epoll_wait(int epfd, struct rte_epoll_event *events, > int maxevents, int timeout); >=20 > +/** > + * It waits for events on the epoll instance. > + * Does not retry if signal received. > + * > + * @param epfd > + * Epoll instance fd on which the caller wait for events. > + * @param events > + * Memory area contains the events that will be available for the call= er. > + * @param maxevents > + * Up to maxevents are returned, must greater than zero. > + * @param timeout It would be good to mention the units here, but might add complexities depe= nding on the functionality supported by the underlying OS. > + * Specifying a timeout of -1 causes a block indefinitely. > + * Specifying a timeout equal to zero cause to return immediately. > + * @return > + * - On success, returns the number of available event. > + * - On failure, a negative value. > + */ > +__rte_experimental > +int > +rte_epoll_wait_interruptible(int epfd, struct rte_epoll_event *events, > + int maxevents, int timeout); > + > /** > * It performs control operations on epoll instance referred by the epfd= . > * It requests that the operation op be performed for the target fd. > diff --git a/lib/librte_eal/freebsd/eal/eal_interrupts.c > b/lib/librte_eal/freebsd/eal/eal_interrupts.c > index f6831b7902c5..d3f8fd78a1ee 100644 > --- a/lib/librte_eal/freebsd/eal/eal_interrupts.c > +++ b/lib/librte_eal/freebsd/eal/eal_interrupts.c > @@ -649,6 +649,18 @@ rte_epoll_wait(int epfd, struct rte_epoll_event > *events, > return -ENOTSUP; > } >=20 > +int > +rte_epoll_wait_interruptible(int epfd, struct rte_epoll_event *events, > + int maxevents, int timeout) > +{ > + RTE_SET_USED(epfd); > + RTE_SET_USED(events); > + RTE_SET_USED(maxevents); > + RTE_SET_USED(timeout); > + > + return -ENOTSUP; > +} > + > int > rte_epoll_ctl(int epfd, int op, int fd, struct rte_epoll_event *event) = { diff -- > git a/lib/librte_eal/linux/eal/eal_interrupts.c > b/lib/librte_eal/linux/eal/eal_interrupts.c > index 1955324d3045..b6ae12a282e7 100644 > --- a/lib/librte_eal/linux/eal/eal_interrupts.c > +++ b/lib/librte_eal/linux/eal/eal_interrupts.c > @@ -1239,9 +1239,9 @@ rte_intr_tls_epfd(void) > return RTE_PER_LCORE(_epfd); > } >=20 > -int > -rte_epoll_wait(int epfd, struct rte_epoll_event *events, > - int maxevents, int timeout) > +static int > +eal_epoll_wait(int epfd, struct rte_epoll_event *events, > + int maxevents, int timeout, bool interruptible) > { > struct epoll_event evs[maxevents]; > int rc; > @@ -1255,29 +1255,40 @@ rte_epoll_wait(int epfd, struct rte_epoll_event > *events, > if (epfd =3D=3D RTE_EPOLL_PER_THREAD) > epfd =3D rte_intr_tls_epfd(); >=20 > - while (1) { > - rc =3D epoll_wait(epfd, evs, maxevents, timeout); > - if (likely(rc > 0)) { > - /* epoll_wait has at least one fd ready to read */ > - rc =3D eal_epoll_process_event(evs, rc, events); > - break; > - } else if (rc < 0) { > - if (errno =3D=3D EINTR) > - continue; > +retry: I guess it is a personal choice. I personally prefer using goto for error h= andling. > + rc =3D epoll_wait(epfd, evs, maxevents, timeout); > + if (likely(rc > 0)) { > + /* epoll_wait has at least one fd ready to read */ > + rc =3D eal_epoll_process_event(evs, rc, events); > + } else if (rc < 0) { > + if (errno =3D=3D EINTR) { > + if (!interruptible) > + goto retry; > + } else { > /* epoll_wait fail */ > - RTE_LOG(ERR, EAL, "epoll_wait returns with > fail %s\n", > + RTE_LOG(ERR, EAL, > + "epoll_wait returns with fail %s\n", > strerror(errno)); > - rc =3D -1; > - break; > - } else { > - /* rc =3D=3D 0, epoll_wait timed out */ > - break; > } > } >=20 > return rc; > } >=20 > +int > +rte_epoll_wait(int epfd, struct rte_epoll_event *events, > + int maxevents, int timeout) > +{ > + return eal_epoll_wait(epfd, events, maxevents, timeout, false); } > + > +int > +rte_epoll_wait_interruptible(int epfd, struct rte_epoll_event *events, > + int maxevents, int timeout) > +{ > + return eal_epoll_wait(epfd, events, maxevents, timeout, true); } > + > static inline void > eal_epoll_data_safe_free(struct rte_epoll_event *ev) { diff --git > a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map > index 234487787994..e1aeb99ba9c8 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -331,6 +331,7 @@ EXPERIMENTAL { > rte_dev_hotplug_handle_enable; > rte_dev_iterator_init; > rte_dev_iterator_next; > + rte_epoll_wait_interruptible; > rte_extmem_attach; > rte_extmem_detach; > rte_extmem_register; > -- > 2.20.1