From patchwork Tue Jun 25 20:57:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 11016405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9960F112C for ; Tue, 25 Jun 2019 20:58:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 893D7205FD for ; Tue, 25 Jun 2019 20:58:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D7B828498; Tue, 25 Jun 2019 20:58:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0A2B205FD for ; Tue, 25 Jun 2019 20:58:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbfFYU6U (ORCPT ); Tue, 25 Jun 2019 16:58:20 -0400 Received: from mail-eopbgr140054.outbound.protection.outlook.com ([40.107.14.54]:20873 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726434AbfFYU6T (ORCPT ); Tue, 25 Jun 2019 16:58:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=testarcselector01; d=microsoft.com; cv=none; b=g3LjwOPN+QO17UIV7beJj1sCN8IeFZ9dRjAFKHOYqjUn/aD/Tdp4y1JQpJXP3bZoRZ0jYGVia/Z/KJOMju237mvfj3X7lG6F9zR2le+w07OJu0ruFWmQ2cmmSrSJMCVlzoXCkElMSqQr113zQnaH6TpSCHU38T6hJdyi5A8Tuc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=testarcselector01; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=578e5j8kfp+LzvkvjN05M50aSkO2YMDolFGh4vPA414=; b=kI0EjysRrHXQyp4CIn812vPsRm2WeAK4AIxy3+wq3WnQMuCITtfIdZezMaV9WQJMTYezSbGbB/T5mL5wMEVp8QhPVd5aJLdVUq1St8KcCrTegxs4V8OYsIKjdc5mwE/NfgluK7VVd1iiISfCIzDWls5XcknmysmBAmYKJwQtiRQ= ARC-Authentication-Results: i=1; test.office365.com 1;spf=none;dmarc=none;dkim=none;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=578e5j8kfp+LzvkvjN05M50aSkO2YMDolFGh4vPA414=; b=j5bOcyDkRntOpvquvzRklY7aoejmaCAH4ed4q6CIUI+fMFDSFsEfr96jyb0F2YdDv5+THeTo7lwBtRepc6QUR7zt90CUdtLqahjF/W0dyIugitGrOqj22GpuaRQXNoeJ4qz5tghrOQxeDWAdtEk6SeKCI+ASFwb1ysw7zKrQ5gI= Received: from DB6PR0501MB2759.eurprd05.prod.outlook.com (10.172.227.7) by DB6PR0501MB2696.eurprd05.prod.outlook.com (10.172.225.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Tue, 25 Jun 2019 20:57:46 +0000 Received: from DB6PR0501MB2759.eurprd05.prod.outlook.com ([fe80::a901:6951:59de:3278]) by DB6PR0501MB2759.eurprd05.prod.outlook.com ([fe80::a901:6951:59de:3278%2]) with mapi id 15.20.2008.014; Tue, 25 Jun 2019 20:57:46 +0000 From: Saeed Mahameed To: "David S. Miller" , Doug Ledford , Jason Gunthorpe CC: Leon Romanovsky , Or Gerlitz , Sagi Grimberg , Tal Gilboa , "netdev@vger.kernel.org" , "linux-rdma@vger.kernel.org" , Yamin Friedman , Max Gurtovoy , Saeed Mahameed Subject: [for-next V2 07/10] linux/dim: Add completions count to dim_sample Thread-Topic: [for-next V2 07/10] linux/dim: Add completions count to dim_sample Thread-Index: AQHVK5ijSF/ZYzzr40ys7bGdzT1+bw== Date: Tue, 25 Jun 2019 20:57:46 +0000 Message-ID: <20190625205701.17849-8-saeedm@mellanox.com> References: <20190625205701.17849-1-saeedm@mellanox.com> In-Reply-To: <20190625205701.17849-1-saeedm@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.21.0 x-originating-ip: [209.116.155.178] x-clientproxiedby: BYAPR03CA0025.namprd03.prod.outlook.com (2603:10b6:a02:a8::38) To DB6PR0501MB2759.eurprd05.prod.outlook.com (2603:10a6:4:84::7) authentication-results: spf=none (sender IP is ) smtp.mailfrom=saeedm@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 776ed448-0b56-4506-6cbb-08d6f9afc626 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:DB6PR0501MB2696; x-ms-traffictypediagnostic: DB6PR0501MB2696: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:398; x-forefront-prvs: 0079056367 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(396003)(136003)(376002)(366004)(346002)(199004)(189003)(6512007)(66476007)(186003)(86362001)(305945005)(3846002)(26005)(6116002)(68736007)(7736002)(102836004)(50226002)(99286004)(14444005)(53936002)(6636002)(76176011)(1076003)(2906002)(5660300002)(6436002)(64756008)(14454004)(66556008)(25786009)(486006)(52116002)(73956011)(71190400001)(6486002)(6506007)(11346002)(81166006)(71200400001)(446003)(386003)(66946007)(256004)(81156014)(66446008)(478600001)(4326008)(66066001)(8676002)(107886003)(2616005)(36756003)(316002)(476003)(8936002)(110136005)(54906003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0501MB2696;H:DB6PR0501MB2759.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: rMBghmfs1Lsju1Tk0iFV9K9ftPVYOe1DSPbz/AVxG+vV+KnfNI6J7dpqHqUWFIg3GiDzY+pXv8akyBPNBxlyxtWHwPldbM5inOxnCp7dKYksgyMrQcwor5xERDRkYTEmIQYnVtDYAaKAC/wkIJPbqTpLpK82ZSJNf+dvrFtg2KCl7ZVi1eW3u563zem1GEOr7sGu7Q2flA0BUx72PXhG0hXdr83JW931/m5FQuhO5+WMKAkB5UyMhUGcXuLIFBwopmzakA8tK4efHg3LcqtcCLNWb68Deb/4RSy125FWt4viH3+8Vj1tEWvFvvxHaTwdpP0n4a+lb8hYyltLHD5YF84UB4BooqUf8CZ42HhH7jv4YWkbBqWH09UH82clR6dTMKPE4FQW3FuyrcnZMGhk9H1y0tKTgRETYBGbAoGckYE= MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 776ed448-0b56-4506-6cbb-08d6f9afc626 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2019 20:57:46.3377 (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: saeedm@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2696 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yamin Friedman Added a measurement of completions per/msec to allow for completion based dim algorithms. In order to use dynamic interrupt moderation with RDMA we need to have a different measurment than packets per second. This change is meant to prepare for adding a new DIM method. All drivers that use net_dim and thus do not need a completion count will have the completions set to 0. Signed-off-by: Yamin Friedman Reviewed-by: Max Gurtovoy Signed-off-by: Saeed Mahameed --- include/linux/dim.h | 28 +++++++++++++++++++++++++--- lib/dim/dim.c | 9 +++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/include/linux/dim.h b/include/linux/dim.h index f48ede3e0322..aa9bdd47a648 100644 --- a/include/linux/dim.h +++ b/include/linux/dim.h @@ -37,6 +37,7 @@ struct dim_cq_moder { u16 usec; u16 pkts; + u16 comps; u8 cq_period_mode; }; @@ -54,6 +55,7 @@ struct dim_sample { u32 pkt_ctr; u32 byte_ctr; u16 event_ctr; + u32 comp_ctr; }; /** @@ -65,9 +67,11 @@ struct dim_sample { * @epms: Events per msec */ struct dim_stats { - int ppms; - int bpms; - int epms; + int ppms; /* packets per msec */ + int bpms; /* bytes per msec */ + int epms; /* events per msec */ + int cpms; /* completions per msec */ + int cpe_ratio; /* ratio of completions to events */ }; /** @@ -89,6 +93,7 @@ struct dim { u8 state; struct dim_stats prev_stats; struct dim_sample start_sample; + struct dim_sample measuring_sample; struct work_struct work; u8 profile_ix; u8 mode; @@ -246,6 +251,23 @@ dim_update_sample(u16 event_ctr, u64 packets, u64 bytes, struct dim_sample *s) s->event_ctr = event_ctr; } +/** + * dim_update_sample_with_comps - set a sample's fields with given + * values including the completion parameter + * @event_ctr: number of events to set + * @packets: number of packets to set + * @bytes: number of bytes to set + * @comps: number of completions to set + * @s: DIM sample + */ +static inline void +dim_update_sample_with_comps(u16 event_ctr, u64 packets, u64 bytes, u64 comps, + struct dim_sample *s) +{ + dim_update_sample(event_ctr, packets, bytes, s); + s->comp_ctr = comps; +} + /* Net DIM */ /* diff --git a/lib/dim/dim.c b/lib/dim/dim.c index 17d5236759bd..439d641ec796 100644 --- a/lib/dim/dim.c +++ b/lib/dim/dim.c @@ -62,6 +62,8 @@ void dim_calc_stats(struct dim_sample *start, struct dim_sample *end, u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr); u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr, start->byte_ctr); + u32 ncomps = BIT_GAP(BITS_PER_TYPE(u32), end->comp_ctr, + start->comp_ctr); if (!delta_us) return; @@ -70,5 +72,12 @@ void dim_calc_stats(struct dim_sample *start, struct dim_sample *end, curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us); curr_stats->epms = DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC, delta_us); + curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, delta_us); + if (curr_stats->epms != 0) + curr_stats->cpe_ratio = + (curr_stats->cpms * 100) / curr_stats->epms; + else + curr_stats->cpe_ratio = 0; + } EXPORT_SYMBOL(dim_calc_stats);