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 7AD2AA0597; Thu, 9 Apr 2020 06:45:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C87751C10F; Thu, 9 Apr 2020 06:45:02 +0200 (CEST) Received: from integrity.niometrics.com (integrity.niometrics.com [42.61.70.122]) by dpdk.org (Postfix) with ESMTP id 3ED121BF9A for ; Thu, 9 Apr 2020 06:45:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by integrity.niometrics.com (Postfix) with ESMTP id 938C2409CBA9; Thu, 9 Apr 2020 12:44:57 +0800 (+08) DKIM-Filter: OpenDKIM Filter v2.11.0 integrity.niometrics.com 938C2409CBA9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niometrics.com; s=default; t=1586407498; bh=g627GgFpFe8tv2pj8K7mr/CF+gh5HeB3oqMOSyDUs9o=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ZV2X9GFZLcneQA7bwxeRLlcpc+3HzEuufS7kvF51Ex4RnK3UABTNrxgkMI5txSpdl XvCKRb/YfRgyGkhKD2Sr+7EQN1DK6zbCvDx+YhaZCoCpc4/qc+IqTGan6fXMabMALq Mj8oO8W31o/pZO/rfHv576cDttqikps3JTeaRsRQ= X-Virus-Scanned: amavisd-new at niometrics.com Received: from integrity.niometrics.com ([127.0.0.1]) by localhost (integrity.niometrics.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hmsNqEcrmUq6; Thu, 9 Apr 2020 12:44:57 +0800 (+08) Received: from [10.15.0.132] (unknown [10.15.0.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by integrity.niometrics.com (Postfix) with ESMTPSA id 196F5409CBA8; Thu, 9 Apr 2020 12:44:55 +0800 (+08) DMARC-Filter: OpenDMARC Filter v1.3.2 integrity.niometrics.com 196F5409CBA8 DKIM-Filter: OpenDKIM Filter v2.11.0 integrity.niometrics.com 196F5409CBA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niometrics.com; s=default; t=1586407497; bh=g627GgFpFe8tv2pj8K7mr/CF+gh5HeB3oqMOSyDUs9o=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=gmF/AJPCgr3Ec8KcNk4rgwe8VQw9u56fSFanXi04d45eEiQSlOlo94SrrKDQVsRT8 R0BJuHQPKgFeH4cygTjY2GaLSl2HapD0kho3bd/vPN3/Dck/8zmUXOyH0uMy0Z1wVe EOeXbAHL5IwxnIXYHOHE2g1koMuD2b/UbW0UrR+A= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) From: Mohsin Shaikh In-Reply-To: Date: Thu, 9 Apr 2020 12:44:55 +0800 Cc: akozyrev@mellanox.com Content-Transfer-Encoding: quoted-printable Message-Id: <34D03F2C-61CD-499B-A258-7165330AF9A2@niometrics.com> References: To: dev@dpdk.org X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Spam-Status: No, score=-1.1 required=3.5 tests=ALL_TRUSTED, AWL, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on integrity.niometrics.com Subject: Re: [dpdk-dev] [Bug 440] net/mlx5: Read of "out_of_buffer" using fopen/fscanf/fclose causing TLB shootdowns due to mmap/munmap 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" Resending.=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D commit 89681d3655f27d758537ae01a02d500deee1acd6 Author: Mohsin Shaikh Date: Thu Apr 9 12:19:45 2020 +0800 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 The details can be found here: https://bugs.dpdk.org/show_bug.cgi?id=3D440 =20 Bugzilla ID: 440 diff --git a/drivers/net/mlx5/mlx5_stats.c = b/drivers/net/mlx5/mlx5_stats.c index 205e4fe..91ac933 100644 --- a/drivers/net/mlx5/mlx5_stats.c +++ b/drivers/net/mlx5/mlx5_stats.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include =20 #include #include @@ -139,20 +141,22 @@ 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); =20 - 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[32]; + ssize_t n =3D read(fd, buf, sizeof(buf)); + close(fd); + if (n !=3D -1) { + sscanf(buf, "%" SCNu64, stat); return; + } } } *stat =3D 0; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Thanks, Mohsin > On 9 Apr 2020, at 12:26 PM, Mohsin Shaikh = wrote: >=20 > Hi Alexander, >=20 > Thank you for your quick response. Please find attached the patch for = bug 440.=20 >=20 > - Mohsin >=20 >=20 >=20 >> On 9 Apr 2020, at 1:07 AM, bugzilla@dpdk.org wrote: >>=20 >> https://bugs.dpdk.org/show_bug.cgi?id=3D440 >>=20 >> Alexander Kozyrev (akozyrev@mellanox.com) changed: >>=20 >> What |Removed |Added >> = --------------------------------------------------------------------------= -- >> Ever confirmed|0 |1 >> Status|UNCONFIRMED |CONFIRMED >> CC| |akozyrev@mellanox.com >>=20 >> --- Comment #1 from Alexander Kozyrev (akozyrev@mellanox.com) --- >> Hi Mohsin, thank you for the problem description and especially for = the patch. >> Would you mind sending this patch to DPDK mailing list so we can = integrate it? >> The patch looks really good to me. The only small thing I would like = to change. >> Could you please use SCNu64 macro instead of "%lu" in the sscanf = function? >> sscanf(buf, "%" SCNu64, stat); >>=20 >> --=20 >> You are receiving this mail because: >> You reported the bug. >=20