From patchwork Thu Jul 7 14:21:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12909732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3251BC433EF for ; Thu, 7 Jul 2022 14:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235553AbiGGOV6 (ORCPT ); Thu, 7 Jul 2022 10:21:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235447AbiGGOV5 (ORCPT ); Thu, 7 Jul 2022 10:21:57 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 638AB1F2C9 for ; Thu, 7 Jul 2022 07:21:56 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id j22so6454250ejs.2 for ; Thu, 07 Jul 2022 07:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EkVm6Tj567au41lZbQzHU6rDunPtyf325TXT17WpCBw=; b=Ke2+5ceqRO+8rY9vXF2EzKFnGZ2MSmhb5570R36Q7imz63bhgZvucZ6jS7KiNzd/Mf e3kd9L4dhMDqVeDi2DP6GK1ABwdEHHuE2a6qXLbsrKOBx7+/p8qFTo6L4ySF3fe/kJOD W6Jc4G+k0TZ4vUmp6QZAZT8YzMf2VsmEHtAIUcqpBnsQ0o2ST1iN7O2D/lIuhOO/2Jh0 pxOLQBdn+HQg310MAO1IlGEEW9B5Nbn2ZrmHmDoTaQtUTA2FDSRzLEnZHHqOoKShGOrM RIDHwMK1riDeIxZ5Vl14dv2nHePhdSk8WEcVZ710N91H3HaUKEm80osB+wEA56pjzGhx t8dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EkVm6Tj567au41lZbQzHU6rDunPtyf325TXT17WpCBw=; b=fHsLym5SsX8uLW+bs/5rI5pPG8cW29sz9k+/uTXMNNwxpUynpuvFFRbHm0bVWG1dDE 1M73PMdjaov5UkuaHGBMuRiRI5AMqRIGf0MRQGSsh3/mNFsayybZEzLQnGGspoGc8l/w bpur3KuygqtIoUJeV891uWC6ZMhoV+TJ9SbqcLS6H9Au74KeDo2se4AGrijumXid7n3g yHr+JkW1aSv3KlBeAW1FLg/AJxUbaTKMQNxlJxvqlWA90i4ml49N5NA5yDZ3/MTy/3BW W2sosXTVIvekh9kpKFwfRR7h5Vxms10B4my+DZ6yfXkQBdUoTrnRHy92R4cwzoYxSOKB lQ4Q== X-Gm-Message-State: AJIora9ljJufDeHlWerK2bpn+m5AX6+N+9ZsoFCYLHJrE26ILDZtGeu8 O6Iux0xbwxnAPFercsiL4TJpDxWtanFCtA== X-Google-Smtp-Source: AGRyM1tYhigiRpJwSHJbGo7Or9jdVhqArLu69WZ2wsdwE8Cu4bWv4WKiDlBQUh0VkosqcIMmWPbd2A== X-Received: by 2002:a17:907:3da2:b0:718:c108:663c with SMTP id he34-20020a1709073da200b00718c108663cmr44543961ejc.252.1657203714911; Thu, 07 Jul 2022 07:21:54 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id 2-20020a170906200200b0072b13fa5e4csm693807ejo.58.2022.07.07.07.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 07:21:54 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Aleksei Marov Subject: [PATCH for-next 1/5] RDMA/rtrs-srv: Fix modinfo output for stringify Date: Thu, 7 Jul 2022 16:21:40 +0200 Message-Id: <20220707142144.459751-2-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707142144.459751-1-haris.iqbal@ionos.com> References: <20220707142144.459751-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang stringify works with define, not enum. Fixes: 91fddedd439c ("RDMA/rtrs: private headers with rtrs protocol structs and helpers") Cc: jinpu.wang@ionos.com Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal Reviewed-by: Aleksei Marov --- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index 9a1e5c2ae55c..ac0df734eba8 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -23,6 +23,17 @@ #define RTRS_PROTO_VER_STRING __stringify(RTRS_PROTO_VER_MAJOR) "." \ __stringify(RTRS_PROTO_VER_MINOR) +/* + * Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) + * and the minimum chunk size is 4096 (2^12). + * So the maximum sess_queue_depth is 65536 (2^16) in theory. + * But mempool_create, create_qp and ib_post_send fail with + * "cannot allocate memory" error if sess_queue_depth is too big. + * Therefore the pratical max value of sess_queue_depth is + * somewhere between 1 and 65534 and it depends on the system. + */ +#define MAX_SESS_QUEUE_DEPTH 65535 + enum rtrs_imm_const { MAX_IMM_TYPE_BITS = 4, MAX_IMM_TYPE_MASK = ((1 << MAX_IMM_TYPE_BITS) - 1), @@ -46,16 +57,6 @@ enum { MAX_PATHS_NUM = 128, - /* - * Max IB immediate data size is 2^28 (MAX_IMM_PAYL_BITS) - * and the minimum chunk size is 4096 (2^12). - * So the maximum sess_queue_depth is 65536 (2^16) in theory. - * But mempool_create, create_qp and ib_post_send fail with - * "cannot allocate memory" error if sess_queue_depth is too big. - * Therefore the pratical max value of sess_queue_depth is - * somewhere between 1 and 65534 and it depends on the system. - */ - MAX_SESS_QUEUE_DEPTH = 65535, MIN_CHUNK_SIZE = 8192, RTRS_HB_INTERVAL_MS = 5000, From patchwork Thu Jul 7 14:21:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12909733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA713C43334 for ; Thu, 7 Jul 2022 14:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235558AbiGGOWB (ORCPT ); Thu, 7 Jul 2022 10:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235447AbiGGOWB (ORCPT ); Thu, 7 Jul 2022 10:22:01 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C55AD1C136 for ; Thu, 7 Jul 2022 07:21:59 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id sb34so32655808ejc.11 for ; Thu, 07 Jul 2022 07:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hTjG8PXY+YuIS3N2xNViy8w3A7zlBpO3NbxQK2TYjxI=; b=Kej0GfDI+pIZuWocUYYEpOyhl5KXAEn2YKsB7EFTc8ry3QU4XqeakyUDC8Vhcibaew /wAT9k05JhZ6TaNrTPmiwZp9GeDnTwWb1SaDv7iZiMcSvFxIKptdo7+PRqvebVZlSYAX 8YdnSWNQXnARi0HEYumXdNgjEwP9ZdxMlKRTx/zdNGw8EJWYvBaB0jsThsrOiGCCemTh FzmKjJoTb+xJQX4xu8ZPJ1v2OZZEWegHeEB8sF8SB2b+1yVJGxSOP7yRQ2O57epb9Qrg 9A68zXQki83c2/D9fI00Q5PBb9YjvJ7bPqi4X2LiID0KqnxY3CZN3TSZY8F0mKZPsXPF I7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hTjG8PXY+YuIS3N2xNViy8w3A7zlBpO3NbxQK2TYjxI=; b=u6NUsMfU/Hx3kwDwqWWito9jATuaJLz3vWCX6SdK2LZ1KG38PNEROkvEmhQRBfgjYe hxoiSPa/KFoJ4foJJbmQnlpm3RCVzDWQ+x+lCgTQu2kJSMb9aCZE62unewyw0hK9IC3K gHkbAYciGiNmsBCVElXpl3jfEHXgwwC3me9XDNKw7g5ei4Xikj5eIP/TayYsv4inYk6J umIFCbZ7qYBk/HeD4IbkWYyOBkQuVgLdh8uECPTqc3wtqwbyXeh9XmrwB4LE++U6DAjS K1I7jv5Vq5SWpmaw+I6CuO5QzimDLSOFdTqwc/GNaQk/dgzXkC8KmqqxDhzeMfl0Tte8 bzDg== X-Gm-Message-State: AJIora+pf0JE1BeD8/7JR3jDjXOXuIji/47nKG7ttHPKoQyctJ/HtC0q LlVux4b6GxsReEPYpMUfE7IrS9p+rGyjmg== X-Google-Smtp-Source: AGRyM1uKtja/w1lKGVB4KQHad6mwbgioQp0nGyjqzGO79dx9xiufo2zSmN7J/0sg+dgm+8fzD5ccZg== X-Received: by 2002:a17:906:a245:b0:708:ce69:e38b with SMTP id bi5-20020a170906a24500b00708ce69e38bmr45468498ejb.100.1657203718295; Thu, 07 Jul 2022 07:21:58 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id 2-20020a170906200200b0072b13fa5e4csm693807ejo.58.2022.07.07.07.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 07:21:57 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Santosh Kumar Pradhan , Christoph Lameter Subject: [PATCH for-next 2/5] RDMA/rtrs-clt: Use this_cpu_ API for stats Date: Thu, 7 Jul 2022 16:21:41 +0200 Message-Id: <20220707142144.459751-3-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707142144.459751-1-haris.iqbal@ionos.com> References: <20220707142144.459751-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Santosh Kumar Pradhan Use this_cpu_x() for increasing/adding a percpu counter through a percpu pointer without the need to disable/enable preemption. Suggested-by: Christoph Lameter Signed-off-by: Santosh Kumar Pradhan Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal Acked-by: Guoqing Jiang Reviewed-by: Christoph Lameter --- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c index 385a19846c24..1e6ffafa2db3 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c @@ -32,11 +32,7 @@ void rtrs_clt_update_wc_stats(struct rtrs_clt_con *con) void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats) { - struct rtrs_clt_stats_pcpu *s; - - s = get_cpu_ptr(stats->pcpu_stats); - s->rdma.failover_cnt++; - put_cpu_ptr(stats->pcpu_stats); + this_cpu_inc(stats->pcpu_stats->rdma.failover_cnt); } int rtrs_clt_stats_migration_from_cnt_to_str(struct rtrs_clt_stats *stats, char *buf) @@ -169,12 +165,8 @@ int rtrs_clt_reset_all_stats(struct rtrs_clt_stats *s, bool enable) static inline void rtrs_clt_update_rdma_stats(struct rtrs_clt_stats *stats, size_t size, int d) { - struct rtrs_clt_stats_pcpu *s; - - s = get_cpu_ptr(stats->pcpu_stats); - s->rdma.dir[d].cnt++; - s->rdma.dir[d].size_total += size; - put_cpu_ptr(stats->pcpu_stats); + this_cpu_inc(stats->pcpu_stats->rdma.dir[d].cnt); + this_cpu_add(stats->pcpu_stats->rdma.dir[d].size_total, size); } void rtrs_clt_update_all_stats(struct rtrs_clt_io_req *req, int dir) From patchwork Thu Jul 7 14:21:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12909734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D760C433EF for ; Thu, 7 Jul 2022 14:22:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235447AbiGGOWF (ORCPT ); Thu, 7 Jul 2022 10:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235560AbiGGOWC (ORCPT ); Thu, 7 Jul 2022 10:22:02 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9041D322 for ; Thu, 7 Jul 2022 07:22:00 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id ez10so2554485ejc.13 for ; Thu, 07 Jul 2022 07:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3rQK0PC6IOiiryPESRzx3KixUMPmNPp4FkWIkxEc+cM=; b=ZszIKxVgvL05vum3kqhu0MKniNd2ddUNm3df2/svYuq5gJvKvlwBsWg58iePbaMEoH pV8HLAOKOE6Ug5hYmMBGQixFiHtZxlZ9yTVx25O5a3zpgMEyr5nsaESkk0cP/gZAy/pI VdRkgyOVSg1Yq3E4YIDU7SGkoLYjORikamIFWuAMpLnETAi6yoQSg1ZkakCCKN0cwtNo EC091mLZ0kANFniPoxytx2BKRUynLkvepAGgPLUeGSmJgpFLfhs00fia+rBTpOELlMqE 9uTn0kvK4K6GVID07MmGBa5WBU6J4/HllLwEta7Zk7wIyAjQelJ2IkE54RIYjXtqAKbC +CNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3rQK0PC6IOiiryPESRzx3KixUMPmNPp4FkWIkxEc+cM=; b=65UrHQK5q8/sCbwaJKmmeHv/uG0+VnBZAS8a21DwjB+8Lpieghy9D700H0Jqh9mLI3 LRVk9HKdcBOHiuy2nOe3SMsv6DVoHJOgG36k6sXGWn6AEycWWi/ZIAjBvs7kXvbQmfnO HEfTPmTuGB5I3KaJ6qx4IbdOhYcxypoZNppmnKkGyV9L6Cq1CzeGVhrGHF/dl8PcY/Ry pCQ1aVHz4kjOyDM/C06Z2mMRpNVs+0tXnagFv7fWPPVJ3kJ/qT9L+KrtOJXeV0HsA51t ow4rip+HJvPk0ABnYKnjJADzH+NQiq8kxD80HikyXABaS2zNwioxWXhah5nh8WkIhPr8 +mGg== X-Gm-Message-State: AJIora9mCFaJeywM842OtP9u7l/UUrPZj6L1y+TQn3ZPUC/dtNbKV9vv xukpGEHJS7FhKNPLcFXOEmtDHUB9rtVjtA== X-Google-Smtp-Source: AGRyM1u8IETFZKxX4yjm+UWhIE9tCBzBFCUNsP+chjAbWBNIRafbiUFYj0j3vs4SGxIpIwR77ImGcA== X-Received: by 2002:a17:907:6e1e:b0:726:be5e:7130 with SMTP id sd30-20020a1709076e1e00b00726be5e7130mr45996904ejc.381.1657203720350; Thu, 07 Jul 2022 07:22:00 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id 2-20020a170906200200b0072b13fa5e4csm693807ejo.58.2022.07.07.07.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 07:21:59 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Santosh Kumar Pradhan Subject: [PATCH for-next 3/5] RDMA/rtrs-srv: Use per-cpu variables for rdma stats Date: Thu, 7 Jul 2022 16:21:42 +0200 Message-Id: <20220707142144.459751-4-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707142144.459751-1-haris.iqbal@ionos.com> References: <20220707142144.459751-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Santosh Kumar Pradhan Convert server stat counters from atomic to per-cpu variables. Signed-off-by: Santosh Kumar Pradhan Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 32 +++++++++++++++----- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 ++ drivers/infiniband/ulp/rtrs/rtrs-srv.c | 9 +++++- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 15 ++++----- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c index 44b1c1652131..2aff1213a19d 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c @@ -14,9 +14,14 @@ int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable) { if (enable) { - struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats; + int cpu; + struct rtrs_srv_stats_rdma_stats *r; + + for_each_possible_cpu(cpu) { + r = per_cpu_ptr(stats->rdma_stats, cpu); + memset(r, 0, sizeof(*r)); + } - memset(r, 0, sizeof(*r)); return 0; } @@ -25,11 +30,22 @@ int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable) ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats, char *page) { - struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats; + int cpu; + struct rtrs_srv_stats_rdma_stats sum; + struct rtrs_srv_stats_rdma_stats *r; + + memset(&sum, 0, sizeof(sum)); + + for_each_possible_cpu(cpu) { + r = per_cpu_ptr(stats->rdma_stats, cpu); + + sum.dir[READ].cnt += r->dir[READ].cnt; + sum.dir[READ].size_total += r->dir[READ].size_total; + sum.dir[WRITE].cnt += r->dir[WRITE].cnt; + sum.dir[WRITE].size_total += r->dir[WRITE].size_total; + } - return sysfs_emit(page, "%lld %lld %lld %lldn %u\n", - (s64)atomic64_read(&r->dir[READ].cnt), - (s64)atomic64_read(&r->dir[READ].size_total), - (s64)atomic64_read(&r->dir[WRITE].cnt), - (s64)atomic64_read(&r->dir[WRITE].size_total), 0); + return sysfs_emit(page, "%llu %llu %llu %llu\n", + sum.dir[READ].cnt, sum.dir[READ].size_total, + sum.dir[WRITE].cnt, sum.dir[WRITE].size_total); } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index b94ae12c2795..2a3c9ac64a42 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -220,6 +220,8 @@ static void rtrs_srv_path_stats_release(struct kobject *kobj) stats = container_of(kobj, struct rtrs_srv_stats, kobj_stats); + free_percpu(stats->rdma_stats); + kfree(stats); } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 24024bce2566..8278d3600a36 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1513,6 +1513,7 @@ static void free_path(struct rtrs_srv_path *srv_path) kobject_del(&srv_path->kobj); kobject_put(&srv_path->kobj); } else { + free_percpu(srv_path->stats->rdma_stats); kfree(srv_path->stats); kfree(srv_path); } @@ -1755,13 +1756,17 @@ static struct rtrs_srv_path *__alloc_path(struct rtrs_srv_sess *srv, if (!srv_path->stats) goto err_free_sess; + srv_path->stats->rdma_stats = alloc_percpu(struct rtrs_srv_stats_rdma_stats); + if (!srv_path->stats->rdma_stats) + goto err_free_stats; + srv_path->stats->srv_path = srv_path; srv_path->dma_addr = kcalloc(srv->queue_depth, sizeof(*srv_path->dma_addr), GFP_KERNEL); if (!srv_path->dma_addr) - goto err_free_stats; + goto err_free_percpu; srv_path->s.con = kcalloc(con_num, sizeof(*srv_path->s.con), GFP_KERNEL); @@ -1813,6 +1818,8 @@ static struct rtrs_srv_path *__alloc_path(struct rtrs_srv_sess *srv, kfree(srv_path->s.con); err_free_dma_addr: kfree(srv_path->dma_addr); +err_free_percpu: + free_percpu(srv_path->stats->rdma_stats); err_free_stats: kfree(srv_path->stats); err_free_sess: diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.h b/drivers/infiniband/ulp/rtrs/rtrs-srv.h index 6292e87f6afd..186a63c217df 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h @@ -12,6 +12,7 @@ #include #include +#include #include "rtrs-pri.h" /* @@ -29,15 +30,15 @@ enum rtrs_srv_state { */ struct rtrs_srv_stats_rdma_stats { struct { - atomic64_t cnt; - atomic64_t size_total; + u64 cnt; + u64 size_total; } dir[2]; }; struct rtrs_srv_stats { - struct kobject kobj_stats; - struct rtrs_srv_stats_rdma_stats rdma_stats; - struct rtrs_srv_path *srv_path; + struct kobject kobj_stats; + struct rtrs_srv_stats_rdma_stats __percpu *rdma_stats; + struct rtrs_srv_path *srv_path; }; struct rtrs_srv_con { @@ -130,8 +131,8 @@ void close_path(struct rtrs_srv_path *srv_path); static inline void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s, size_t size, int d) { - atomic64_inc(&s->rdma_stats.dir[d].cnt); - atomic64_add(size, &s->rdma_stats.dir[d].size_total); + this_cpu_inc(s->rdma_stats->dir[d].cnt); + this_cpu_add(s->rdma_stats->dir[d].size_total, size); } /* functions which are implemented in rtrs-srv-stats.c */ From patchwork Thu Jul 7 14:21:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12909735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA67DC43334 for ; Thu, 7 Jul 2022 14:22:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235215AbiGGOWG (ORCPT ); Thu, 7 Jul 2022 10:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235561AbiGGOWF (ORCPT ); Thu, 7 Jul 2022 10:22:05 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0F9C23165 for ; Thu, 7 Jul 2022 07:22:03 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a9so2981434ejf.6 for ; Thu, 07 Jul 2022 07:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uHPqIaxLqgWf7NR1j5EX5ARr+fAYM2yGQ7O88dTMNcI=; b=DFWnFgPsFYhdag8PxLNU/hYYHcoRjM36y+XRZ4q+SCwy9TkXMXmpJ7G5mEnPc3QXa2 koPsFiSrNvRbjt1kkBTT44KqA1OSd4WzVkk4/IeRArOhoPm5BcIhPDCO2IM/vjcG0uTz S1m6o4NYDx9CUj2UuGlbuuX5afVTZbBfOaN+wtwVD0pZ6L9IMkPzFeyeQ8+KokIc9Q7D l38qmmxab3u+VIGy9OUQcqIpFpd1SroGNRkw2d5NUG3jBJx+tUtvAaF36DNO6KZA1Q5e XtlGB0Kk6QGlt19vmy3ZKbFxq+pBHKUB9PB3UYo67P2IJodBJseZFLr1RNFMYqoVG1QP RauQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uHPqIaxLqgWf7NR1j5EX5ARr+fAYM2yGQ7O88dTMNcI=; b=5uZewalvRIC7wZch280wL7fheUlVZcQjAj+tvIdKpN/JxjQwnM5o22A02trmThXb30 XwUPUshYN38dmquM0f1uMZrCnGT9+e50enza5w0uargkLDoUPHjmWMpcRwMUxACwROrq GrZlrMfSrv7pG05nP3aeCC9Bf6EmqV7CS/HxWyVJZ3isXT0hdJUyIiaV+oH9Tkv0Hp0Q AdwX48su7JPmuTpP+DQYnWs97ynX4ovnMuaeeMdNa0JDaTeCwWxwsnAyw1C/As4HBHb5 vuj4Q9cog3V7Q1ZLwf5IMgVfF67gEs6DzVg5XItbYpZH07DKmxk/IdFfGH0z/Xs8YNax KWAQ== X-Gm-Message-State: AJIora+Oo3OfKHDIs/t+fPF3XAR4sX8nDrqXCKvqYZNf45to+PjCEVcE 5jFk1oDKlEif2G6Cci1S6LqDYgaBJkXTMg== X-Google-Smtp-Source: AGRyM1tjpX3Ai4hAWBgJzgHXL3GHonbEe3/u2wFu0Q0x3XhZPLP7lEDQuzw24JBTZAm2S9byH5QSeA== X-Received: by 2002:a17:907:724a:b0:726:3713:cfd3 with SMTP id ds10-20020a170907724a00b007263713cfd3mr47062756ejc.460.1657203722064; Thu, 07 Jul 2022 07:22:02 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id 2-20020a170906200200b0072b13fa5e4csm693807ejo.58.2022.07.07.07.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 07:22:01 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com Subject: [PATCH for-next 4/5] rtrs-clt: Replace list_next_or_null_rr_rcu with an inline function Date: Thu, 7 Jul 2022 16:21:43 +0200 Message-Id: <20220707142144.459751-5-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707142144.459751-1-haris.iqbal@ionos.com> References: <20220707142144.459751-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org removes list_next_or_null_rr_rcu macro to fix below warnings. That macro is used only twice. CHECK:MACRO_ARG_REUSE: Macro argument reuse 'head' - possible side-effects? CHECK:MACRO_ARG_REUSE: Macro argument reuse 'ptr' - possible side-effects? CHECK:MACRO_ARG_REUSE: Macro argument reuse 'memb' - possible side-effects? Replaces that macro with an inline function. Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality") Cc: jinpu.wang@ionos.com Signed-off-by: Md Haris Iqbal Suggested-by: Jason Gunthorpe Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 35 ++++++++++++-------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index 9809c3883979..525f083fcaeb 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -740,25 +740,25 @@ struct path_it { struct rtrs_clt_path *(*next_path)(struct path_it *it); }; -/** - * list_next_or_null_rr_rcu - get next list element in round-robin fashion. +/* + * rtrs_clt_get_next_path_or_null - get clt path from the list or return NULL * @head: the head for the list. - * @ptr: the list head to take the next element from. - * @type: the type of the struct this is embedded in. - * @memb: the name of the list_head within the struct. + * @clt_path: The element to take the next clt_path from. * - * Next element returned in round-robin fashion, i.e. head will be skipped, + * Next clt path returned in round-robin fashion, i.e. head will be skipped, * but if list is observed as empty, NULL will be returned. * - * This primitive may safely run concurrently with the _rcu list-mutation + * This function may safely run concurrently with the _rcu list-mutation * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock(). */ -#define list_next_or_null_rr_rcu(head, ptr, type, memb) \ -({ \ - list_next_or_null_rcu(head, ptr, type, memb) ?: \ - list_next_or_null_rcu(head, READ_ONCE((ptr)->next), \ - type, memb); \ -}) +static inline struct rtrs_clt_path * +rtrs_clt_get_next_path_or_null(struct list_head *head, struct rtrs_clt_path *clt_path) +{ + return list_next_or_null_rcu(head, &clt_path->s.entry, typeof(*clt_path), s.entry) ?: + list_next_or_null_rcu(head, + READ_ONCE((&clt_path->s.entry)->next), + typeof(*clt_path), s.entry); +} /** * get_next_path_rr() - Returns path in round-robin fashion. @@ -789,10 +789,8 @@ static struct rtrs_clt_path *get_next_path_rr(struct path_it *it) path = list_first_or_null_rcu(&clt->paths_list, typeof(*path), s.entry); else - path = list_next_or_null_rr_rcu(&clt->paths_list, - &path->s.entry, - typeof(*path), - s.entry); + path = rtrs_clt_get_next_path_or_null(&clt->paths_list, path); + rcu_assign_pointer(*ppcpu_path, path); return path; @@ -2277,8 +2275,7 @@ static void rtrs_clt_remove_path_from_arr(struct rtrs_clt_path *clt_path) * removed. If @sess is the last element, then @next is NULL. */ rcu_read_lock(); - next = list_next_or_null_rr_rcu(&clt->paths_list, &clt_path->s.entry, - typeof(*next), s.entry); + next = rtrs_clt_get_next_path_or_null(&clt->paths_list, clt_path); rcu_read_unlock(); /* From patchwork Thu Jul 7 14:21:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12909736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0054CCA479 for ; Thu, 7 Jul 2022 14:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235561AbiGGOWH (ORCPT ); Thu, 7 Jul 2022 10:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235560AbiGGOWH (ORCPT ); Thu, 7 Jul 2022 10:22:07 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C410E1C136 for ; Thu, 7 Jul 2022 07:22:05 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id r21so3922224eju.0 for ; Thu, 07 Jul 2022 07:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sm88g2jYKtACpjqLwOPhgJtSKR5newRCaR/+fqpcw4Q=; b=KmkpuORm84QPsvOuq0sRXI/pU13ZjAbQ1Ug+Fidd1WE1r8txBb7qw2hYuyXjwrylRA IiJcGKkptYWck0KstfYGOC8x1GwJBIbffje4tw9QMiHPJUlOewp2N1ler159EhGC38cp hVA6RIOtUdPPnT28SfKRVpsXh0hlj6TIs2DXMy9RPYLdF9WHC35ZZN/B69UUGqrD0P1/ 7HDCGjPXb0S4pNhoWxbNEVAnepAmWY2WM76M1bLqanwLe68aHDhYe2wQ4h8ZvPTUqJK4 /fSnqwSiX1wjP6Eor9JgoJCJfR4yuCaFsTKNx1cLLtL2nH7rqcdGCTBn3FmRmEiBcvZZ XajA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sm88g2jYKtACpjqLwOPhgJtSKR5newRCaR/+fqpcw4Q=; b=Tp8kHqvxmI0FGryXP37ifxEuzePWFodhQfN+WHyloxgmlgtUku8fcKiSRvd10hLrt+ 8A+kt5PNwn2shFp3Xed230Jwsue6u1fj4WdK2QZEi0fH63+AsNz3aySGLATUiBIjJUhH GN0aiYjPlZQUmu7LRUuB2X1R5k9ElwaGoRISVBwvXCpVKmRQnAVizaipacg48NS/KWUG 8UxkHJqV4mOTQFIltsBpFtGzmoKz2oKYPPfcNLJyfbXRfuCWDGxUvkha5QSRCvhRH2Ux XoqYpCOGKDAbHyajrXUGaSgBMdOncEE4ZKCl8ar7PrCdW45kR9I2Ov5rleKM1knh5+Go U55A== X-Gm-Message-State: AJIora+BvH3eRBBv2Sym+PHm37DJ2MnEIX5wD1eyg1c/ldCGnMaEfBWQ kstlXsDM8zyJvYxT4spfI+gBA86miCj6Fw== X-Google-Smtp-Source: AGRyM1vDzkADFeBsohgOyDcVT3C8SB+4Zx0pQi8cV7FxDrxNnhx+9wh9kfvTuHBO9aL3bgpbG9z+Kg== X-Received: by 2002:a17:906:3f49:b0:722:e1d2:f857 with SMTP id f9-20020a1709063f4900b00722e1d2f857mr45712084ejj.15.1657203724241; Thu, 07 Jul 2022 07:22:04 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id 2-20020a170906200200b0072b13fa5e4csm693807ejo.58.2022.07.07.07.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 07:22:03 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: leon@kernel.org, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim Subject: [PATCH for-next 5/5] RDMA/rtrs-srv: Do not use mempool for page allocation Date: Thu, 7 Jul 2022 16:21:44 +0200 Message-Id: <20220707142144.459751-6-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707142144.459751-1-haris.iqbal@ionos.com> References: <20220707142144.459751-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang The mempool is for guaranteed memory allocation during extreme VM load (see the header of mempool.c of the kernel). But rtrs-srv allocates pages only when creating new session. There is no need to use the mempool. With the removal of mempool, rtrs-server no longer need to reserve huge mount of memory, this will avoid error like this: https://www.spinics.net/lists/kernel/msg4404829.html Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal Acked-by: Guoqing Jiang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 8278d3600a36..34c03bde5064 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -11,7 +11,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt #include -#include #include "rtrs-srv.h" #include "rtrs-log.h" @@ -26,11 +25,7 @@ MODULE_LICENSE("GPL"); #define DEFAULT_SESS_QUEUE_DEPTH 512 #define MAX_HDR_SIZE PAGE_SIZE -/* We guarantee to serve 10 paths at least */ -#define CHUNK_POOL_SZ 10 - static struct rtrs_rdma_dev_pd dev_pd; -static mempool_t *chunk_pool; struct class *rtrs_dev_class; static struct rtrs_srv_ib_ctx ib_ctx; @@ -1358,7 +1353,7 @@ static void free_srv(struct rtrs_srv_sess *srv) WARN_ON(refcount_read(&srv->refcount)); for (i = 0; i < srv->queue_depth; i++) - mempool_free(srv->chunks[i], chunk_pool); + __free_pages(srv->chunks[i], get_order(max_chunk_size)); kfree(srv->chunks); mutex_destroy(&srv->paths_mutex); mutex_destroy(&srv->paths_ev_mutex); @@ -1411,7 +1406,8 @@ static struct rtrs_srv_sess *get_or_create_srv(struct rtrs_srv_ctx *ctx, goto err_free_srv; for (i = 0; i < srv->queue_depth; i++) { - srv->chunks[i] = mempool_alloc(chunk_pool, GFP_KERNEL); + srv->chunks[i] = alloc_pages(GFP_KERNEL, + get_order(max_chunk_size)); if (!srv->chunks[i]) goto err_free_chunks; } @@ -1424,7 +1420,7 @@ static struct rtrs_srv_sess *get_or_create_srv(struct rtrs_srv_ctx *ctx, err_free_chunks: while (i--) - mempool_free(srv->chunks[i], chunk_pool); + __free_pages(srv->chunks[i], get_order(max_chunk_size)); kfree(srv->chunks); err_free_srv: @@ -2273,14 +2269,10 @@ static int __init rtrs_server_init(void) err); return err; } - chunk_pool = mempool_create_page_pool(sess_queue_depth * CHUNK_POOL_SZ, - get_order(max_chunk_size)); - if (!chunk_pool) - return -ENOMEM; rtrs_dev_class = class_create(THIS_MODULE, "rtrs-server"); if (IS_ERR(rtrs_dev_class)) { err = PTR_ERR(rtrs_dev_class); - goto out_chunk_pool; + goto out_err; } rtrs_wq = alloc_workqueue("rtrs_server_wq", 0, 0); if (!rtrs_wq) { @@ -2292,9 +2284,7 @@ static int __init rtrs_server_init(void) out_dev_class: class_destroy(rtrs_dev_class); -out_chunk_pool: - mempool_destroy(chunk_pool); - +out_err: return err; } @@ -2302,7 +2292,6 @@ static void __exit rtrs_server_exit(void) { destroy_workqueue(rtrs_wq); class_destroy(rtrs_dev_class); - mempool_destroy(chunk_pool); rtrs_rdma_dev_pd_deinit(&dev_pd); }