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 41F3EA0577; Tue, 14 Apr 2020 16:17:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 720551C1F2; Tue, 14 Apr 2020 16:17:09 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70083.outbound.protection.outlook.com [40.107.7.83]) by dpdk.org (Postfix) with ESMTP id 7489E1C0CB; Tue, 14 Apr 2020 16:17:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K+SB+JkMkE+0wzWfWDkQ+NXCGyng8y5NZgSFad1cF8AI2HiiUxgzUSi2ntNzsRgwTr+tZXyRSoCchgDMD3YuerHaoNZl9JpHZc3iPII7RdL5CU86i8DofVCKwnneaD+FvuSlnUuLq6CqH2bVbohMPIqL4oY/Qcoun0JGWpmIRuPsPwo2535B/x5He1AgBRrR3Nn9vlfopJh4d2475+LvwQnEEv5IVNlBsBlLIsYuF9vmL0+Wqz1+wc91fmYd0V//HCYKCbK4QK3OVuRO5yHsCahKUGl4M2DEvG9044ae1HF2AgxStiqcfNKDw3I3YN2PKv71thlfT0HuGaIXnstE5Q== 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=DL00RC14yp1imsK7k8QT3CemH4LeM4FOWsFphT1yda0=; b=N3gzkp1h9tUYpp2LaWspfPBu9V1ZEiVtFUVQw6ilW2yR2EouZylat0i67rGU7TJ/2Z7YUtB7ZiFxmNAeQ++4fAkAtWvGwcHE97+5/7AvN38Y4iRkcu6SR1fEBaEKEM/q/OsTnKBFfs79kyf+WLA4QuM9ihm8aVEzAWrtEss4IXLylpuenFzLEO1JcwINY8JE9uMZixAWd3jPKXrWcqV8Qe6GkpK3m9F9hnNV7XGq1/3g7XN1rqCswR7vlHad56/H48dCoP0NyVcEGOTYtQD2ahl40IonVF3Qq5/b0Xi1Al83oTdMh1nTTpXCnqpGY93ej+5OdQCjn2j5ftSzlhP0uQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DL00RC14yp1imsK7k8QT3CemH4LeM4FOWsFphT1yda0=; b=Urn1F2T3hiIxkgLEXO+m9khwL3jicpxRGImeg5JlSgHvZTuUvTowhMGJEQXUkxMHLIAAMrHDtZPngW0vSrbBclGyxt42L5OqfV+QM/7RPGz3MrE8kupD3nvlc0pwdEO5X7KvpGIQhhw1GJBNKyZtI/65zGRaHETwzE8sPNpjiBc= Received: from AM0PR05MB6707.eurprd05.prod.outlook.com (2603:10a6:20b:15b::17) by AM0PR05MB5635.eurprd05.prod.outlook.com (2603:10a6:208:119::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15; Tue, 14 Apr 2020 14:17:06 +0000 Received: from AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e]) by AM0PR05MB6707.eurprd05.prod.outlook.com ([fe80::508:747b:cc12:5f6e%6]) with mapi id 15.20.2900.028; Tue, 14 Apr 2020 14:17:06 +0000 From: Raslan Darawsheh To: Mohsin Shaikh , "dev@dpdk.org" CC: "stable@dpdk.org" , Alexander Kozyrev , Slava Ovsiienko Thread-Topic: [dpdk-dev] [PATCH] net/mlx5: use open/read/close for reading ib stat Thread-Index: AQHWDq8GY6SkeErX2UaqVmwTShHDLah4sSxg Date: Tue, 14 Apr 2020 14:17:06 +0000 Message-ID: References: <1586464626-12958-1-git-send-email-mohsinshaikh@niometrics.com> In-Reply-To: <1586464626-12958-1-git-send-email-mohsinshaikh@niometrics.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; x-originating-ip: [188.161.230.106] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 4e9f3ae1-094a-4d8d-f591-08d7e07e833d x-ms-traffictypediagnostic: AM0PR05MB5635:|AM0PR05MB5635: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:268; x-forefront-prvs: 0373D94D15 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB6707.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(39850400004)(366004)(136003)(376002)(396003)(346002)(8676002)(7696005)(9686003)(8936002)(5660300002)(66556008)(55016002)(81156014)(66446008)(64756008)(52536014)(76116006)(316002)(107886003)(4326008)(71200400001)(2906002)(66946007)(66476007)(26005)(186003)(54906003)(6506007)(53546011)(86362001)(478600001)(33656002)(110136005); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pPQ0pXqg9R96VzF/084aBA6gja5CH7fvFq2XrGsxu1u2F2ZkcfQFDu3plCTnWomPvUkL/U2HHcpdrfHaoYk9AwaX7qkrejKoxoyoSF749eZwE0RiyevLC6a7xk0kV1jd84qqwH0NMavAjH/XRVntcT0ctdMR3pb6z3QgAdMG0GQ2FMNk74QH8VcHIxDuFeW+z4VjrT+i31HwST0gtA0lwz9e7Q7gVjFqXKM2exxrThCY2JF2H3f9/QVOaoPq8+ad84KpwVD9KLTTPT0m4wR+eIWmDv5doQG8mcUJoHNF//wEIe2YzIN1ozH8vx5MM+QEoKX3DKfB36dnTl+6MlxkRSJeShwI6jt/UjzxZTenn3vI2DxNhjEbjNjDhHcaMiN9oEYLfCx2+Vyp0vyN+CvFN875iTYjHMRZi9cFSBGadPLbE/Kq8bqOLSJta1RS/wyN x-ms-exchange-antispam-messagedata: kS83a6l5YJkPlqN53buFm40VNqiF6HXfU65pOUG+3DkQHKG7AnA95O4oz/pPIPs6i5CWpXN79Nayvn94xFA6ZHsPRiLHONlqQhAuTXJrH2MqQBZ099VZM4EhEu2vok330kN67wvvTBA0eVDnXQWvLA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e9f3ae1-094a-4d8d-f591-08d7e07e833d X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Apr 2020 14:17:06.7526 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: W2RxdENPeJwTPiP02JFZhe1nvT5CrvfF5GgC2/c6rJuvqFK+79BnvWBjSTqUGZ6wnBJo8ZUCHuqmhep8wE5IGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB5635 Subject: Re: [dpdk-dev] [PATCH] net/mlx5: use open/read/close for reading ib stat 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, > -----Original Message----- > From: dev On Behalf Of Mohsin Shaikh > Sent: Thursday, April 9, 2020 11:37 PM > To: dev@dpdk.org > Cc: stable@dpdk.org; Alexander Kozyrev ; > Mohsin Shaikh > Subject: [dpdk-dev] [PATCH] net/mlx5: use open/read/close for reading ib > stat >=20 > fgets(3)/fread(3)/fscanf(3) etc. use mmap(2)/munmap(2) which leads > to TLB shootdown interrupts to all dpdk app cores including RX cores. > This can cause packet drops. Use read(2)/write(2) instead. >=20 > Bugzilla ID: 440 > Cc: stable@dpdk.org >=20 > Signed-off-by: Mohsin Shaikh > --- > drivers/net/mlx5/mlx5_stats.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_stats.c b/drivers/net/mlx5/mlx5_stats.= c > index 7603502..b2c09d8 100644 > --- a/drivers/net/mlx5/mlx5_stats.c > +++ b/drivers/net/mlx5/mlx5_stats.c > @@ -3,11 +3,13 @@ > * Copyright 2015 Mellanox Technologies, Ltd > */ >=20 > +#include > #include > #include > #include > #include > #include > +#include >=20 > #include > #include > @@ -142,20 +144,23 @@ > static inline void > mlx5_read_ib_stat(struct mlx5_priv *priv, const char *ctr_name, uint64_t > *stat) > { > - FILE *file; > + int fd; > + > if (priv->sh) { > MKSTR(path, "%s/ports/%d/hw_counters/%s", > priv->sh->ibdev_path, > priv->ibv_port, > ctr_name); > - > - file =3D fopen(path, "rb"); > - if (file) { > - int n =3D fscanf(file, "%" SCNu64, stat); > - > - fclose(file); > - if (n =3D=3D 1) > + fd =3D open(path, O_RDONLY); > + if (fd !=3D -1) { > + char buf[21] =3D {'\0'}; > + ssize_t n =3D read(fd, buf, sizeof(buf)); > + > + close(fd); > + if (n !=3D -1) { > + *stat =3D strtoull(buf, NULL, 10); > return; > + } > } > } > *stat =3D 0; > -- > 1.8.3.1 Patch rebased and applied to next-net-mlx, Kindest regards Raslan Darawsheh