From patchwork Tue Jul 12 10:31:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12914711 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 56A82C433EF for ; Tue, 12 Jul 2022 10:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229542AbiGLKbU (ORCPT ); Tue, 12 Jul 2022 06:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbiGLKbT (ORCPT ); Tue, 12 Jul 2022 06:31:19 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEDBBACF7B for ; Tue, 12 Jul 2022 03:31:17 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id b11so13476399eju.10 for ; Tue, 12 Jul 2022 03:31:17 -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=GkIHH2Ahbid+FYB44EYLzMTMDtkpdayGc6PenViyfVM=; b=ivpzQvpxny/dw6aIY3BWhSy0Pjb2v8yPpJUWiXp/tUEO8CgSVhJU1r/wSGxM3OXuJu N2DIr/RopwhQvr3uaVXwyXwp3vjEz1SuYuQwf+5iDzEAd4sTdfiK3dEPKbdrago36sZp 9VlXlQJSWLSBwEUzeCw9wZzzAVjIMIBX4QW0Dhem/OOAKZKt3YJPTACI2uavABkvr4nN GGzvUt/SsJUIFnYem+K/SQ/+Wo+HEARPPIbeRI2wgfFaJ0T2PF9vXi7lpRZndaKQCakV tT3huOYuU+G8njX12ZK9kQlZogiTNuesAvldVRuwpszVEpQFjPYqZKGidYXWuNHGAWzF PLNg== 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=GkIHH2Ahbid+FYB44EYLzMTMDtkpdayGc6PenViyfVM=; b=L9Ggs8mkSgysK9H1UCrlckKbAgoa6CO7qYqaVzAFAXG4hwAVrgarTJjObnxKpJTscP dAKQaY/WbSMHSUdBlNStYJ9QKxLSTcXfBXd1Khq/Q5XyEaXO68FyDZj1S/riLuWofMqK nAvJv04uGV3ZO9z20RW0xk/H26APbNZ3st8BiJ1g5qMl07cBrI3CZCRPYqTKHab23CFA Eu6nGr6sdoFPF+dlZ86+4lSFiq6gh4C+HS1J4HhHx4tevt475R/0w5IK6ti0QqJv3mBR cQG6QzarkG90h9HlbZkNxbCfh3o78MRdB42E+GeRXRwRssHkHm1Tfz4cG/ZtqL32gVyb lfbw== X-Gm-Message-State: AJIora9U3sSXSR4gjIB2flNTZKNZvGw/V+Q1azLP9qCVLeQIFS+CRjLW 3opLFJjpGYg84SELYqNwjdCKaRmqX+JYYA== X-Google-Smtp-Source: AGRyM1saiqwusGhPjaHKsNRFC1p0n7UaucK22iMykVZ+IwB51ds/qOg9FCNKhEflJxmGYeeLfXk7TA== X-Received: by 2002:a17:907:734a:b0:72b:7c72:e6b3 with SMTP id dq10-20020a170907734a00b0072b7c72e6b3mr3266834ejc.608.1657621876448; Tue, 12 Jul 2022 03:31:16 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n18-20020aa7c452000000b004355d27799fsm5763419edr.96.2022.07.12.03.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 03:31:15 -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 v2 for-next 1/5] RDMA/rtrs-srv: Fix modinfo output for stringify Date: Tue, 12 Jul 2022 12:31:09 +0200 Message-Id: <20220712103113.617754-2-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712103113.617754-1-haris.iqbal@ionos.com> References: <20220712103113.617754-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 --- v1 -> v2: No change 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 Tue Jul 12 10:31:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12914712 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 7CC38C43334 for ; Tue, 12 Jul 2022 10:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229559AbiGLKbV (ORCPT ); Tue, 12 Jul 2022 06:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiGLKbT (ORCPT ); Tue, 12 Jul 2022 06:31:19 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2379AD84C for ; Tue, 12 Jul 2022 03:31:18 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id x91so9537049ede.1 for ; Tue, 12 Jul 2022 03:31:18 -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=bL2qFotsttP72TZdh1Jw0d0woxIFD2og+CMnPKgAXYY=; b=KeWDfrGGEwuRkvIPPsLBuajm8gP0tsZxMs+TOnqXGsvaStxh9ViaLuAeIK6bwxIQyr bgPaIuFNUf8MVJJGxUKi7xnOgpThEKllMU03F83AV2PmJm22edGMyN7row+H0nMJ9kqT IepSFdOxPhxkEU23ADX1qhTy61bNk48sQBd4Ur5dKMEGfGn583flEWTbX9kLyEekiysg LQliwKcawEOzOG/6xvkT/QN9XdbRO7Vhg5JpCbUJkaAmScA2jRh+w4b5/I8vuXZkqZGz xDsD+5ejA3y1/SxfavVdYojXzhh92TpkeoLD09Q8pFeCVwZnqhC8RK0PgWxb/X3rUQ7D JUWw== 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=bL2qFotsttP72TZdh1Jw0d0woxIFD2og+CMnPKgAXYY=; b=vtwZt/sTYRw9Jc9XXV/X6fBJJ1Bs3CMn30ft4s7tn0lOuVDFezP9gWn//c9MKLBgBJ Gfvbvc4um04O3QylPHTJ6sekTcl6uftjcfdqve1RMnCMIb8mHdpeqfsNI5oCYWTgxKRg sryoP7PF3lshb3AY74OEwKiXBxtPdmmkBMgGpEqCfmlG24jdsvxg32/F2P3xJEIdNrR8 Cq12+ssH1hpC5zd8dYk8R8YUIurBD3DkTs5GPvQjqBxK86b5I+cPDmkwaBH56T5DjWMs qYbaesHZF1IiU0bprUSo+HkjtOi/O8va+koJDZwXrZzuzBu8ghmc38KGk59q6Tgh9V3L bOlA== X-Gm-Message-State: AJIora/5lnhNXxXaA5Skwd2qF+1GVOvCkkTbB6pjB/0hMMUIbmCLsNJF g/9j6N381N69XmYZMb6IvsCRHfDBixVrvw== X-Google-Smtp-Source: AGRyM1uepjpLH6x3kJ24L0TX6IZztVtqy+xGJqJCGT8ppM8zuMRAVWFEstYWDEKr43KF+CWCu0TvQA== X-Received: by 2002:a05:6402:1e94:b0:43a:9e92:bf2 with SMTP id f20-20020a0564021e9400b0043a9e920bf2mr30870995edf.248.1657621877397; Tue, 12 Jul 2022 03:31:17 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n18-20020aa7c452000000b004355d27799fsm5763419edr.96.2022.07.12.03.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 03:31:16 -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 , Guoqing Jiang Subject: [PATCH v2 for-next 2/5] RDMA/rtrs-clt: Use this_cpu_ API for stats Date: Tue, 12 Jul 2022 12:31:10 +0200 Message-Id: <20220712103113.617754-3-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712103113.617754-1-haris.iqbal@ionos.com> References: <20220712103113.617754-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 --- v1 -> v2: Added Acked-by, Reviewed-by. 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 Tue Jul 12 10:31:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12914713 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 780D6C433EF for ; Tue, 12 Jul 2022 10:31:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbiGLKbV (ORCPT ); Tue, 12 Jul 2022 06:31:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbiGLKbU (ORCPT ); Tue, 12 Jul 2022 06:31:20 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD3D7ACEF8 for ; Tue, 12 Jul 2022 03:31:19 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id b11so13476519eju.10 for ; Tue, 12 Jul 2022 03:31:19 -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=gmVujBePXmmrW4p+h3rFQiuS7xsCFgZ6c7Mmdi7TSCU=; b=JcXSBH1uVP/MqNgZnZux0PHVQGy6TTgGoIxozRYQ3LOWZnMmf9MJWznHX39sn4zo2a qXTF5RXNNl1pzThw1L1jLuyMvKWrS5AKFMovDIn515XdfoZ3sfNXR22vvTR+XZGYCljx M+Nd1abxM5pZFlHnKexEx9eiDvwd6o/2/BBzIu8G/pvt21A/nepSpTYFg6ELiUrz8Q54 ne//cC+LaJ6VfIE+JC7wKAjUBSArHoWJdxvIAMiawy4CxtiQdf5YzEhJVvSga/4hhFYt 0Y9ONUS3wkM12Y8/r2E8vZGBwKhlgkG33rVhZRI/mijVTUbcOtBYYlfi5D51/gQS+S4K ZWnQ== 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=gmVujBePXmmrW4p+h3rFQiuS7xsCFgZ6c7Mmdi7TSCU=; b=zZJa/x5Y6jSc9FHh/8x8I5gRW3G+7FXusrRcpdUxHpfVMWnJvDeaVFeqfydnIyyU8x +DrY/mBc2eWLQqkGCz7Vsw0tMQw+qxmHv1RKUpQ3z1RkqsgrdALPqZ4fM5GRUforBZeU dNgSiZNhD5VODuRH7ce6+DNzuJp00Ahf5x+SaT/KCxH2+g+g0xzGQhJvp5Q3w8wLwUNi PZig3JrwJOfU1fYPEK0eIMaxdiakiruDdyi6uwjPd/vjM6sPDSqYfqIq7cnfIT1CHyXS cqRWBj6/6bHesORbKQWpBbjLWcw2oMAsc9J4+cqz5y/zv+Re6DIBRay5BJYSoyEv8bir x9cQ== X-Gm-Message-State: AJIora9EMevTXWaOqSdfloZZZ1AdiTdm6nzyZ0ewozMXjwR54LaEedwj BuceI0caxNIwHwQTxk7rUokt/zpDqcjGYw== X-Google-Smtp-Source: AGRyM1tONuGGVdSEuh2AwZ+Xr21/HHYQGKyeumzsm81GX7FqQaYb0HEegFttQFH5CokHHxbDuM7wFg== X-Received: by 2002:a17:907:6d12:b0:72b:6e70:8c7d with SMTP id sa18-20020a1709076d1200b0072b6e708c7dmr5821860ejc.23.1657621878170; Tue, 12 Jul 2022 03:31:18 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n18-20020aa7c452000000b004355d27799fsm5763419edr.96.2022.07.12.03.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 03:31:17 -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 v2 for-next 3/5] RDMA/rtrs-srv: Use per-cpu variables for rdma stats Date: Tue, 12 Jul 2022 12:31:11 +0200 Message-Id: <20220712103113.617754-4-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712103113.617754-1-haris.iqbal@ionos.com> References: <20220712103113.617754-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 --- v1 -> v2: No change 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 Tue Jul 12 10:31:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12914714 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 2C42AC43334 for ; Tue, 12 Jul 2022 10:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbiGLKb3 (ORCPT ); Tue, 12 Jul 2022 06:31:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbiGLKbX (ORCPT ); Tue, 12 Jul 2022 06:31:23 -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 CD18AAD854 for ; Tue, 12 Jul 2022 03:31:20 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id oy13so8641985ejb.1 for ; Tue, 12 Jul 2022 03:31:20 -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=Rr09vrN0BIW9cbDjJzenRB73ZSEODXyzM/MeK8GSeye4IfnrY9gbNrSksCe2bv5T/T x4Jl5+Zb4fEuV7+I4y9M0AbvNcqF6agU8dHRi/MrzDn7mb2JO8ufvgZHrffXy5/XdLUt EqGOU/rp+F2GD5OhH7DXsESpXJmBhAfOZFa9AWQIW6lMGSwm3RCPIxa5aqiL3wn0zrdQ Eyt8sfdPvbMUOlSRoQ0pV4sJXYA6M5zkRH+yuH5YTSkI8kvYR89awFzsebSXp9zZpGXb +7p3yGgsbUfRxCq0dRqGvc2KNNwD2U2ROHzGxUL5MQx+aIHnNTs9Sbi2DWpwbj9wY8NX NdNw== 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=rxiUlyrmbFiek4iDvfLZswaNLFq6o/QoGeUmzGgOcIA+dcoU+fKj+pKHYgDQElUAPu /XtFw170SSxiHhx20epH8qcULlhi/AOAHkoHd+WxNQNEstuHyYHBdyU3U6FIPBteVvFJ gy8R65/Pz9c+PU6UBUdmI553DYsBtv6mEN3sRqzfHNlCcULkMfDeHLBn4zsBUBwgkuZ9 LBQCupR9L5lXqsB7RUiEN2NMaj2z30mE5ycExigwCRBYCkCOUNLcrlh7D3SE/rD0rSr3 dlCRAWilVhBnu2F8QyIG5d+Ggjsy5l5/WiT4L6ts5fn+qO/TTgfirSnsLvSd8RbzAlSy RIJQ== X-Gm-Message-State: AJIora+0VLMuRGT7u3qYsPNuY9fdawne3D8T1uOcY1NgTaSGdoHPxdEz 2aLdFz2e1P3/Pe5BhyyjFMKcSyqhd/T29g== X-Google-Smtp-Source: AGRyM1uM06d4ZQC0QGTP+mhQQHA9kKMzGpiZFb193r1EknwOIrZu9UYiwIDZccW7DcxyFbM+9aF7hA== X-Received: by 2002:a17:907:2e01:b0:72b:764f:ea1a with SMTP id ig1-20020a1709072e0100b0072b764fea1amr4112315ejc.666.1657621878932; Tue, 12 Jul 2022 03:31:18 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n18-20020aa7c452000000b004355d27799fsm5763419edr.96.2022.07.12.03.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 03:31:18 -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 v2 for-next 4/5] RDMA/rtrs-clt: Replace list_next_or_null_rr_rcu with an inline function Date: Tue, 12 Jul 2022 12:31:12 +0200 Message-Id: <20220712103113.617754-5-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712103113.617754-1-haris.iqbal@ionos.com> References: <20220712103113.617754-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 Tue Jul 12 10:31:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12914715 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 93718C433EF for ; Tue, 12 Jul 2022 10:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbiGLKbd (ORCPT ); Tue, 12 Jul 2022 06:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231593AbiGLKb0 (ORCPT ); Tue, 12 Jul 2022 06:31:26 -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 C148CAD863 for ; Tue, 12 Jul 2022 03:31:21 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id os14so13530472ejb.4 for ; Tue, 12 Jul 2022 03:31:21 -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=tLsLaFia6rSr83SuGaInd17J5TvqZbvWOaZ3ptnS7I4=; b=FdmFVqENBvGRFnU3rNDqodWJVsgFxbKkJFCGMi7bzXLp0IsHvbTQkT7SGcyd/Jqfa7 lp66ud1XCo8czZwpapJWwT7yDvPbki5WBiIfgHjxX5A2xv+Y1LqhVd/xG323dU+5Yp2n ef3BhYk75uZqRjyAzoVKfhBc83AOw++CCqqGoKJEVM/Et1kvP+NCPyBp+pz22vszPCZW 7T3V7hmlNmKmNS/tKVFjP/3yYFHpwS6JnSnA72aDZR6F6sGPXYhOj1A6NnRPDsoNh0JN ux0SRLazOhB/g5Xj9axHtcH4U4QC3nkWMykyQAS9LU4rUL7rujerQxqyGmyY8UMBzDDT 43eQ== 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=tLsLaFia6rSr83SuGaInd17J5TvqZbvWOaZ3ptnS7I4=; b=0Nakc4kAsCFJVqho5vIWZ/S03M+WqAi+aew8Nk5mU5ZTLI6lyCMayK/lBfdpjGfOHL +FiAYvXtO8vQLZyLFkNQHKESiKjFj+NW8pNdjBzTtdOR+LPJ60FWMKPj9OEiWle0oRiO TZpLEzOXElrkZWpuo3Pj6ioVfDRDFPHJr2eQcc2JZbmkbUqnFIE5XhqELqUu5VrS55IF Ol4qN9cfnKpAEzbWCmU6WdQqwij9FFNfFeAwTfJWrGr4UktsOTVVEotbH13H1IHQNOqz or1nqqzRCH3k16u2EjwQXnXmJlqJ07rv/ucEPEBdvX2GU91cTnozB3kfAYUOlN94pHBu qdfA== X-Gm-Message-State: AJIora8BO8+ZsTNpJafAIq8bustBgQQO6ugG4M+hkMUcOZeiNM3SLuFd aGBADELcVFO3JhrvJFGBfJbTyNswx2zEUw== X-Google-Smtp-Source: AGRyM1sIa92Kv1iq2hYYCgJEydv+ynAKb0/thFqV6hUWb12wqYvU/3W8f2uOyWlhZFdGngk0nowQsQ== X-Received: by 2002:a17:906:730f:b0:726:ca34:e605 with SMTP id di15-20020a170906730f00b00726ca34e605mr23174499ejc.347.1657621880170; Tue, 12 Jul 2022 03:31:20 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id n18-20020aa7c452000000b004355d27799fsm5763419edr.96.2022.07.12.03.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 03:31:19 -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, kernel test robot , Gioh Kim , Guoqing Jiang Subject: [PATCH v2 for-next 5/5] RDMA/rtrs-srv: Do not use mempool for page allocation Date: Tue, 12 Jul 2022 12:31:13 +0200 Message-Id: <20220712103113.617754-6-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712103113.617754-1-haris.iqbal@ionos.com> References: <20220712103113.617754-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://lore.kernel.org/lkml/20220620020727.GA3669@xsang-OptiPlex-9020/ Reported-by: kernel test robot Signed-off-by: Gioh Kim Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal Acked-by: Guoqing Jiang --- v1 -> v2: Added Reported-by, Acked-by. Changed email link to lore.kernel.org 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); }