From patchwork Wed Sep 22 12:53:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12510581 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4BFCC433F5 for ; Wed, 22 Sep 2021 12:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E17F61178 for ; Wed, 22 Sep 2021 12:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236027AbhIVMzM (ORCPT ); Wed, 22 Sep 2021 08:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236026AbhIVMzM (ORCPT ); Wed, 22 Sep 2021 08:55:12 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06EF6C061574 for ; Wed, 22 Sep 2021 05:53:42 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id w17so6399866wrv.10 for ; Wed, 22 Sep 2021 05:53:41 -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=TokeasERpDA/o3cDSrmM/KEfSOBhSvrT5GhAQzJxwzg=; b=VGV5UofDVDQihX2TfpeAnoAGrwKFFeQt554W0cIKzHY/MTmA1iYoJoSeofdbykP/8B fzr3Eb1ogkE/32rHsV28Ef2HhRUsc/PV7hIRvUeVLXH8QKqhbZQK0W4+1Q9Nz16p/5Fe ElZ7xMhWFwCFb/XFwW1frnp6Rx1Y0tJY+entD5VPSCQ4DhLjxQnA1k+hO6YOBQjCIS3Y 5/GwzVnTNKgaNEXSIazM801cXNgOI3ZxuQc48fuuK/zKfzVaFQtkiCkXKcjCE814XgT2 8FlZO6vepNhr6LU2Gayp/y8oGVyO/ofNz6CizNzERSvFjaN/Cf/9kJqc5U8KJHFqjsBa MSvQ== 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=TokeasERpDA/o3cDSrmM/KEfSOBhSvrT5GhAQzJxwzg=; b=ADNHTRVx7qwt4dUgKM10legfekha9sHXAEL1ZkZr8oPs+2/Sa4QUKD+I4gGSdVgQ8x yO1OyZc/+Jfby91bf1VptdDpV702Vyo6xoJZ1U99nyqldvP722jigSlLtwBmuLOP5IEf 00ZRDmrAcdE57dGpLl+INCoCudnPPE+a9fE0fgNqM+yYFuiRrKNxwE7BXeJlrN0e2Li6 Eky2w0WRzB3oGs4d3b7RFHPDXBTYA5qkczClx/AQP+OxLfFqtvgabEA2pu73dXdSHlkU GKJe0qUMHdfBn4c4ITwi0AHgdq9DOZIg6tvhSXHLy09bxBRkxfVmyqnQCBCqofy/BJjl ic7w== X-Gm-Message-State: AOAM5306uX0OLFpfOQpPt3QRV86uR+i45E7wLEMxLcq8Bx7zwr76UWr8 HlGk50pMkhavBBgR+pe6u9lu726pEIw7LA== X-Google-Smtp-Source: ABdhPJxWpUyNC4IaWoRee/fYWU74UR9Gqc4qC3d2HCXd6dy07eFDiDaUlHW40CUB4ekZe+BcPhUwZA== X-Received: by 2002:a5d:6d8e:: with SMTP id l14mr41229932wrs.270.1632315220507; Wed, 22 Sep 2021 05:53:40 -0700 (PDT) Received: from nb01533.pb.local ([2001:1438:4010:2540:40a5:9868:5a83:f3b9]) by smtp.gmail.com with ESMTPSA id j20sm2173685wrb.5.2021.09.22.05.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 05:53:40 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com Subject: [PATCH for-next 1/7] RDMA/rtrs: Use sysfs_emit instead of s*printf function for sysfs show Date: Wed, 22 Sep 2021 14:53:27 +0200 Message-Id: <20210922125333.351454-2-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922125333.351454-1-haris.iqbal@ionos.com> References: <20210922125333.351454-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org sysfs_emit function was added to be aware of the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content, so there is no possible overruns. So replace the uses of any s*printf functions for the sysfs show functions with sysfs_emit. Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 24 +++++++++----------- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c index 5e780bdd763d..9c27f21ec040 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c @@ -45,24 +45,23 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, size_t used; int cpu; - used = scnprintf(buf, len, " "); + used = sysfs_emit(buf, " "); for_each_possible_cpu(cpu) - used += scnprintf(buf + used, len - used, " CPU%u", cpu); + used += sysfs_emit_at(buf, used, " CPU%u", cpu); - used += scnprintf(buf + used, len - used, "\nfrom:"); + used += sysfs_emit_at(buf, used, "\nfrom:"); for_each_possible_cpu(cpu) { s = per_cpu_ptr(stats->pcpu_stats, cpu); - used += scnprintf(buf + used, len - used, " %d", + used += sysfs_emit_at(buf, used, " %d", atomic_read(&s->cpu_migr.from)); } - used += scnprintf(buf + used, len - used, "\nto :"); + used += sysfs_emit_at(buf, used, "\nto :"); for_each_possible_cpu(cpu) { s = per_cpu_ptr(stats->pcpu_stats, cpu); - used += scnprintf(buf + used, len - used, " %d", - s->cpu_migr.to); + used += sysfs_emit_at(buf, used, " %d", s->cpu_migr.to); } - used += scnprintf(buf + used, len - used, "\n"); + used += sysfs_emit_at(buf, used, "\n"); return used; } @@ -70,9 +69,8 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, int rtrs_clt_stats_reconnects_to_str(struct rtrs_clt_stats *stats, char *buf, size_t len) { - return scnprintf(buf, len, "%d %d\n", - stats->reconnects.successful_cnt, - stats->reconnects.fail_cnt); + return sysfs_emit(buf, "%d %d\n", stats->reconnects.successful_cnt, + stats->reconnects.fail_cnt); } ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, @@ -94,7 +92,7 @@ ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, sum.failover_cnt += r->failover_cnt; } - return scnprintf(page, len, "%llu %llu %llu %llu %u %llu\n", + return sysfs_emit(page, "%llu %llu %llu %llu %u %llu\n", sum.dir[READ].cnt, sum.dir[READ].size_total, sum.dir[WRITE].cnt, sum.dir[WRITE].size_total, atomic_read(&stats->inflight), sum.failover_cnt); @@ -103,7 +101,7 @@ ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, ssize_t rtrs_clt_reset_all_help(struct rtrs_clt_stats *s, char *page, size_t len) { - return scnprintf(page, len, "echo 1 to reset all statistics\n"); + return sysfs_emit(page, "echo 1 to reset all statistics\n"); } int rtrs_clt_reset_rdma_stats(struct rtrs_clt_stats *stats, bool enable) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c index 20efd44297fb..9c43ce5ba1c1 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c @@ -102,7 +102,7 @@ static ssize_t rtrs_srv_src_addr_show(struct kobject *kobj, sess = container_of(kobj, struct rtrs_srv_sess, kobj); cnt = sockaddr_to_str((struct sockaddr *)&sess->s.dst_addr, page, PAGE_SIZE); - return cnt + scnprintf(page + cnt, PAGE_SIZE - cnt, "\n"); + return cnt + sysfs_emit_at(page, cnt, "\n"); } static struct kobj_attribute rtrs_srv_src_addr_attr = From patchwork Wed Sep 22 12:53:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12510583 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 028DBC433FE for ; Wed, 22 Sep 2021 12:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD81B61178 for ; Wed, 22 Sep 2021 12:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236085AbhIVMzN (ORCPT ); Wed, 22 Sep 2021 08:55:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236035AbhIVMzN (ORCPT ); Wed, 22 Sep 2021 08:55:13 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61840C061756 for ; Wed, 22 Sep 2021 05:53:43 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id t18so6679169wrb.0 for ; Wed, 22 Sep 2021 05:53:43 -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=N6VX/H4c/sdWPmihnLTXpmTVlPKJ98HDRev5YsFguYA=; b=TVb7GJ3rPm00YLTu0j60xQyEQgMRVEjKNSRsptQgiG/6cqAosmLBM9NrJP3EvdOs+S 6Edrn/NepVMglo/+G/+28ZuQlee1LJ8NArP5e6nsMFGH/Mhjo46huln/eYkxBE+lLOwF mVVZwF5kHlaqSLnQW3x9wo3A5T8K8fFXVEnFnVJaUmoac0nxnWjN/RAwoLXODCdSzq6Q Ndi3BtfsCbbjDBx/R48nNi7MAjNxxyovrKLOpsEMCiHMa6y87wf1bv3i/HAgEgMgsIOq QtH/LDmkfsds5uz6X4kQbTpZCDXFoy+D1Nvymm8/49kjrTe+77DETA8wniLf1+vYxFt0 mtBQ== 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=N6VX/H4c/sdWPmihnLTXpmTVlPKJ98HDRev5YsFguYA=; b=1zIXrx6KZytANyjfLTEEwPJHyyrC9Hs7Jqcj5LbqBpVQPVrt41f0awyJpV9fSPvARl MP9AzHRgIPMCOK2HPgVur8QTuT37k6dEVWEDm7MM2se8M54xNiB0ZlQ5J2wmjp6RJ++O T1YzLOxil4A2twW/hEKAtV7Usckp/i17oAwvRV5/DKqN1xs07XThnPZw15i2m8681Atn 8+bRIB5OdQGU32BudqLaUvJb6jNkH/4zI4D7TcR/BKs26OgGMkVwwZi1VjyjLOi/G77L o60xa2gmp3Ypd26EcauCicVsykLyrGQ31Ub3IndhOQvxoBWVPJEPJYFw+lPhI++WWnB6 Jfrg== X-Gm-Message-State: AOAM5327AT4UH2rGcppQ6nqZJfLJMBTUUjMHOvC8ZxaDfq0CGv1KmATd n0i+S5qIio7vYdJh65mCO01ELjjouut9Ew== X-Google-Smtp-Source: ABdhPJx+gzsT8xjrs3GHleSLekTUOUprrJjUiAe/JJDPAUXZDhcOGwgHL9S9+0SfqAcv9Gin7yl7Tw== X-Received: by 2002:a5d:6741:: with SMTP id l1mr41857253wrw.289.1632315221804; Wed, 22 Sep 2021 05:53:41 -0700 (PDT) Received: from nb01533.pb.local ([2001:1438:4010:2540:40a5:9868:5a83:f3b9]) by smtp.gmail.com with ESMTPSA id j20sm2173685wrb.5.2021.09.22.05.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 05:53:41 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com Subject: [PATCH for-next 2/7] RDMA/rtrs: Remove len parameter from helper print functions of sysfs Date: Wed, 22 Sep 2021 14:53:28 +0200 Message-Id: <20210922125333.351454-3-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922125333.351454-1-haris.iqbal@ionos.com> References: <20210922125333.351454-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Since we have changed all sysfs show functions to use sysfs_emit, we do not require the len (PAGE_SIZE) in our helper print functions. So remove it from the function parameter. Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 12 ++++-------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 12 +++++------- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 2 +- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 3 +-- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 3 +-- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c index 9c27f21ec040..61d5e0018392 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c @@ -37,8 +37,7 @@ void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats) s->rdma.failover_cnt++; } -int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, - char *buf, size_t len) +int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, char *buf) { struct rtrs_clt_stats_pcpu *s; @@ -66,15 +65,13 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, return used; } -int rtrs_clt_stats_reconnects_to_str(struct rtrs_clt_stats *stats, char *buf, - size_t len) +int rtrs_clt_stats_reconnects_to_str(struct rtrs_clt_stats *stats, char *buf) { return sysfs_emit(buf, "%d %d\n", stats->reconnects.successful_cnt, stats->reconnects.fail_cnt); } -ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, - char *page, size_t len) +ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, char *page) { struct rtrs_clt_stats_rdma sum; struct rtrs_clt_stats_rdma *r; @@ -98,8 +95,7 @@ ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, atomic_read(&stats->inflight), sum.failover_cnt); } -ssize_t rtrs_clt_reset_all_help(struct rtrs_clt_stats *s, - char *page, size_t len) +ssize_t rtrs_clt_reset_all_help(struct rtrs_clt_stats *s, char *page) { return sysfs_emit(page, "echo 1 to reset all statistics\n"); } diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index 9dc819885ec7..6d81aae53df4 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -224,19 +224,17 @@ void rtrs_clt_update_all_stats(struct rtrs_clt_io_req *req, int dir); int rtrs_clt_reset_rdma_lat_distr_stats(struct rtrs_clt_stats *stats, bool enable); ssize_t rtrs_clt_stats_rdma_lat_distr_to_str(struct rtrs_clt_stats *stats, - char *page, size_t len); + char *page); int rtrs_clt_reset_cpu_migr_stats(struct rtrs_clt_stats *stats, bool enable); -int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, char *buf, - size_t len); +int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, char *buf); int rtrs_clt_reset_reconnects_stat(struct rtrs_clt_stats *stats, bool enable); -int rtrs_clt_stats_reconnects_to_str(struct rtrs_clt_stats *stats, char *buf, - size_t len); +int rtrs_clt_stats_reconnects_to_str(struct rtrs_clt_stats *stats, char *buf); int rtrs_clt_reset_rdma_stats(struct rtrs_clt_stats *stats, bool enable); ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, - char *page, size_t len); + char *page); int rtrs_clt_reset_all_stats(struct rtrs_clt_stats *stats, bool enable); ssize_t rtrs_clt_reset_all_help(struct rtrs_clt_stats *stats, - char *page, size_t len); + char *page); /* rtrs-clt-sysfs.c */ diff --git a/drivers/infiniband/ulp/rtrs/rtrs-pri.h b/drivers/infiniband/ulp/rtrs/rtrs-pri.h index d12ddfa50747..78eac9a4f703 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-pri.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-pri.h @@ -398,7 +398,7 @@ static ssize_t get_value##_show(struct kobject *kobj, \ { \ type *stats = container_of(kobj, type, kobj_stats); \ \ - return print(stats, page, PAGE_SIZE); \ + return print(stats, page); \ } #define STAT_ATTR(type, stat, print, reset) \ diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c index 12c374b5eb6e..44b1c1652131 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c @@ -23,8 +23,7 @@ int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable) return -EINVAL; } -ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats, - char *page, size_t len) +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; diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.h b/drivers/infiniband/ulp/rtrs/rtrs-srv.h index 9d8d2a91a235..7d403c12faf3 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h @@ -136,8 +136,7 @@ static inline void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s, /* functions which are implemented in rtrs-srv-stats.c */ 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, size_t len); +ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats, char *page); int rtrs_srv_reset_all_stats(struct rtrs_srv_stats *stats, bool enable); ssize_t rtrs_srv_reset_all_help(struct rtrs_srv_stats *stats, char *page, size_t len); From patchwork Wed Sep 22 12:53:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12510585 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D6A2C433F5 for ; Wed, 22 Sep 2021 12:53:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EAE5961178 for ; Wed, 22 Sep 2021 12:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236110AbhIVMzO (ORCPT ); Wed, 22 Sep 2021 08:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236035AbhIVMzO (ORCPT ); Wed, 22 Sep 2021 08:55:14 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B1DFC061760 for ; Wed, 22 Sep 2021 05:53:44 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id i23so6578443wrb.2 for ; Wed, 22 Sep 2021 05:53:44 -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=y1UL7Nlf2kMcbJh3azmP4EsiIrVGqW6KQ7WA/oJgmcc=; b=SqUIcK9Rwd2Ch6MV3jrQdSM35JnaIGe6t3wIIdXBWHqdVgAhVWGyUpeJcZQ49dWp7r BfYX76nSKGMlQUAavqXPkbi6mWHZbrE8Ev7H+zGhm4KL5RtS2sW0Q4EjFrkDmBsoOTjz Iaeq1gkGyvzl7SN6uR96x/iyF9AgTlX0eClj+W77unrQGfqCWmdz5pEqfpbBZz1nc+2E koj32j94xH/WP1zo9+0lkeC6siND1X2WnGObXhpLOnhy0/Sp3Pmf3QyxasJLSggBoz/C yggxmsRLnLTXLR1LH0GqJSgXB11DFXspKrl1yN7QQ4sQpaZhlc8gpOJhUkVwsg1GXxrf Pw7w== 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=y1UL7Nlf2kMcbJh3azmP4EsiIrVGqW6KQ7WA/oJgmcc=; b=Y2BvYwkc91SO1JwIm0h2PYd+8dlrMnncWOqh8doFj0Hfz0XFmM4WChDdYwOljToO7G Y5C/dQBO09S9OSF5AtQ/gvNoV6s9qYUQtM+6d7JrfZ7G17adHmXhwxebmWaizhfnk30m edZIj9xQwVIKVWfarhqRHdw0cq11eD8UXMNyNld4hDUVbjVd88e9RH5tB7wTN0h5GT3z mtJECT4+tSVOv+YblHOqz2rbQVUGTngJWlusbfTKtmx8NeK6K9wZhekRh6lRf2z8Sc33 qve9eRwuZVlrqzDmk4gH/l5hSVXwJwmUC4auWWXPAQj/qCoRkOz2nwPniuAYpFqZwFxz nD1Q== X-Gm-Message-State: AOAM5325K2nAg35wVW40+NAFGEizagKko/bk8F9rUJ8PiEhfOtTSDRhM vocSyjC5pt+iU7edGLx0jwky1HAsZHdJ8Q== X-Google-Smtp-Source: ABdhPJxYrg7atfT4c4/LUWdGpPR1dMnAjUDVW8we+kTG+ZBwBNtD4pTwQPvYFXSzWMU6qrrVnseGuw== X-Received: by 2002:adf:e44c:: with SMTP id t12mr42984645wrm.49.1632315222914; Wed, 22 Sep 2021 05:53:42 -0700 (PDT) Received: from nb01533.pb.local ([2001:1438:4010:2540:40a5:9868:5a83:f3b9]) by smtp.gmail.com with ESMTPSA id j20sm2173685wrb.5.2021.09.22.05.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 05:53:42 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Md Haris Iqbal Subject: [PATCH for-next 3/7] RDMA/rtrs: Fix warning when use poll mode on client side. Date: Wed, 22 Sep 2021 14:53:29 +0200 Message-Id: <20210922125333.351454-4-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922125333.351454-1-haris.iqbal@ionos.com> References: <20210922125333.351454-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang when test with poll mode, it will fail and lead to warning below on client side: echo "sessname=bla path=gid:fe80::2:c903:4e:d0b3@gid:fe80::2:c903:8:ca17 device_path=/dev/nullb2 nr_poll_queues=-1" | sudo tee /sys/devices/virtual/rnbd-client/ctl/map_device rnbd_client L597: Mapping device /dev/nullb2 on session bla, (access_mode: rw, nr_poll_queues: 8) WARNING: CPU: 3 PID: 9886 at drivers/infiniband/core/cq.c:447 ib_cq_pool_get+0x26f/0x2a0 [ib_core] The problem is in case of poll queue, we need to still call ib_alloc_cq/ib_free_cq, we can't use cq_poll api for poll queue. As both client and server use shared function from rtrs, set irq_con_num to con_num on server side, which is number of total connection of the session, this way we can differ if the rtrs_con requires pollqueue. Following up patches will replace the duplicate code with helpers. Signed-off-by: Jack Wang Reviewed-by: Gioh Kim Signed-off-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 1 + drivers/infiniband/ulp/rtrs/rtrs.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 716ef7b23558..078a1cbac90c 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -1766,6 +1766,7 @@ static struct rtrs_srv_sess *__alloc_sess(struct rtrs_srv *srv, strscpy(sess->s.sessname, str, sizeof(sess->s.sessname)); sess->s.con_num = con_num; + sess->s.irq_con_num = con_num; sess->s.recon_cnt = recon_cnt; uuid_copy(&sess->s.uuid, uuid); spin_lock_init(&sess->state_lock); diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index ca542e477d38..9bc323490ce3 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -228,7 +228,12 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe, struct rdma_cm_id *cm_id = con->cm_id; struct ib_cq *cq; - cq = ib_cq_pool_get(cm_id->device, nr_cqe, cq_vector, poll_ctx); + if (con->cid >= con->sess->irq_con_num) + cq = ib_alloc_cq(cm_id->device, con, nr_cqe, cq_vector, + poll_ctx); + else + cq = ib_cq_pool_get(cm_id->device, nr_cqe, cq_vector, poll_ctx); + if (IS_ERR(cq)) { rtrs_err(con->sess, "Creating completion queue failed, errno: %ld\n", PTR_ERR(cq)); @@ -283,7 +288,10 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr, max_send_sge); if (err) { - ib_cq_pool_put(con->cq, con->nr_cqe); + if (con->cid >= con->sess->irq_con_num) + ib_free_cq(con->cq); + else + ib_cq_pool_put(con->cq, con->nr_cqe); con->cq = NULL; return err; } @@ -300,7 +308,10 @@ void rtrs_cq_qp_destroy(struct rtrs_con *con) con->qp = NULL; } if (con->cq) { - ib_cq_pool_put(con->cq, con->nr_cqe); + if (con->cid >= con->sess->irq_con_num) + ib_free_cq(con->cq); + else + ib_cq_pool_put(con->cq, con->nr_cqe); con->cq = NULL; } } From patchwork Wed Sep 22 12:53:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12510587 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19C59C433FE for ; Wed, 22 Sep 2021 12:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB23661178 for ; Wed, 22 Sep 2021 12:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236021AbhIVMzP (ORCPT ); Wed, 22 Sep 2021 08:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236035AbhIVMzP (ORCPT ); Wed, 22 Sep 2021 08:55:15 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB5FC061574 for ; Wed, 22 Sep 2021 05:53:45 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id w29so6437515wra.8 for ; Wed, 22 Sep 2021 05:53:45 -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=t1QtuaSx1IRGfCpES7GFcGPcaoZguarMvSswnYe+X4c=; b=VGiOq2CjGYzvVZzPzguwmSnLvJXZK9afLG9bTcyh2ye1Ye+pHVY5YqiJDC+WHCZT7z WZK9wEuhkXnoN9ih1tKsXiKhy3F5QQhV7pK14/WCSGaH3Uwv05NXTPWpp3gTqFUyOIjM WzX0nbSRtEE5gpMQ90DIbGyZBpmLT1+Rn2uLHmySNPqJuCz4Q8aojbPUtzWsfVDhkQz4 iZ09FWrza/+4PBuEA8S+yUtuoN95/Mgc9BF1w4eViImFc2RdYBvJ7d5+7wN4G0VgDWNQ yfj2j/Wimex5JweZ1zgIlKa+EAnrbg+TvU8EgMskGDtMVGNZTjYsoVBI9UQMbNTSeNpy hpnA== 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=t1QtuaSx1IRGfCpES7GFcGPcaoZguarMvSswnYe+X4c=; b=60+at0NBuTe+kzGg9PuSJrbrn3zg6aaZHuNNFv9kLRH8aqj0W4xzOKPHCBfkW/gKYF QF6vU3H97od6eXqre9DR5FOdzmYEWcGv1V8ry4P24fmNCO09kq7zgY3nrWcgUUTVEiIi 6aKmiug2TiCNVd31G+a30D5u0ZaoAu10oy704MYGbhlyz+pSzX9efWmq819tv8HJB5bE nE5I82XRq8CQwzyLL8Zt5tfsGOgnkHngX5nU08DXU4pDQ6Y/W3LcCGY1i11pDCnA4V1X KThFdU+HqkjuX7MSpf2KY7ZGw4JrZXzy6gGRaLyXSasxl+lOmJBINJLljvD4g4TjZ6GS drTA== X-Gm-Message-State: AOAM532PlzbhMu2l+lEH3SWFCNcSTiavkvDFVAxwSrLfBTWKkkeruAFK bcj9h1V8fvGndsYZqQ7DzwGFCtBsS+jWLw== X-Google-Smtp-Source: ABdhPJw0rE5wYyvU2auninJO9NipKfEJZpazuCzx1iar87d4Y5JLAh/AHz2fnjfXKsSCtIobtVI4ZQ== X-Received: by 2002:a7b:cf09:: with SMTP id l9mr10084701wmg.115.1632315223900; Wed, 22 Sep 2021 05:53:43 -0700 (PDT) Received: from nb01533.pb.local ([2001:1438:4010:2540:40a5:9868:5a83:f3b9]) by smtp.gmail.com with ESMTPSA id j20sm2173685wrb.5.2021.09.22.05.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 05:53:43 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com Subject: [PATCH for-next 4/7] RDMA/rtrs: Replace duplicate check with is_pollqueue helper Date: Wed, 22 Sep 2021 14:53:30 +0200 Message-Id: <20210922125333.351454-5-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922125333.351454-1-haris.iqbal@ionos.com> References: <20210922125333.351454-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jack Wang if (con->cid >= con->sess->irq_con_num) check can be replaced with a is_pollqueue helper. Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index 9bc323490ce3..ac83cd97f838 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -222,13 +222,18 @@ static void qp_event_handler(struct ib_event *ev, void *ctx) } } +static bool is_pollqueue(struct rtrs_con *con) +{ + return con->cid >= con->sess->irq_con_num; +} + static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe, enum ib_poll_context poll_ctx) { struct rdma_cm_id *cm_id = con->cm_id; struct ib_cq *cq; - if (con->cid >= con->sess->irq_con_num) + if (is_pollqueue(con)) cq = ib_alloc_cq(cm_id->device, con, nr_cqe, cq_vector, poll_ctx); else @@ -288,7 +293,7 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr, max_send_sge); if (err) { - if (con->cid >= con->sess->irq_con_num) + if (is_pollqueue(con)) ib_free_cq(con->cq); else ib_cq_pool_put(con->cq, con->nr_cqe); @@ -308,7 +313,7 @@ void rtrs_cq_qp_destroy(struct rtrs_con *con) con->qp = NULL; } if (con->cq) { - if (con->cid >= con->sess->irq_con_num) + if (is_pollqueue(con)) ib_free_cq(con->cq); else ib_cq_pool_put(con->cq, con->nr_cqe); From patchwork Wed Sep 22 12:53:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12510591 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8470DC433EF for ; Wed, 22 Sep 2021 12:53:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CEA6610A0 for ; Wed, 22 Sep 2021 12:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236087AbhIVMzT (ORCPT ); Wed, 22 Sep 2021 08:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236104AbhIVMzQ (ORCPT ); Wed, 22 Sep 2021 08:55:16 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DFD5C061760 for ; Wed, 22 Sep 2021 05:53:46 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id t18so6679668wrb.0 for ; Wed, 22 Sep 2021 05:53:46 -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=O8fqFcUdXM0mw2Oj6jRNvBtR9RrzATj3ICpSKMfB0SU=; b=RN85SmZFlOqvGitOlSzORDmWvAEq9F6TIa5H2ET6lC6+n2SbzRiQqxLKOMm3bRg1Sp qcmRtd1NogQ+IITlnQJ7rQPRb8da1XQ1sR42ihYA/8kCaZ1kroI6DBbFeul0Jq+A7l6K OwyQhoMkFyT56Ivo4fW74EH8pl7lxOZBehCMfdsli6Lsr1EGWfTrl9cdyFEzirNoGruI AqhlL8cV+nZaaVlovaMihePZPg70LfjqzD8Orof1AyuYa6M1OxvqDY8+zSKIPzwFBvxX zqYxSN4KbHfL5ErF0PcgIDC4qzAKRzwtGTtlNvsu+CW0obnn0dVC2KafZMD/DwDzwAzN VdkA== 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=O8fqFcUdXM0mw2Oj6jRNvBtR9RrzATj3ICpSKMfB0SU=; b=YGbKKzCRlA23S7G3vUsd6h0ldf45cYylLCLf16bA0fhUBFngYqEmSHaKNG/2XjkQDM T+71r9XulRZz0htAicMHrA9ylSvynqoxUk5sY0UsPMaLzYEcOCr8pf/KwOvOTmkfNgSb 8YvkKpPOavWS0/SJp7TlO3YGRa5+Gel3S1LoOKcav2Kxkn26Ff0bt9E+36kFSoqzFAHT Se9x5JLsU4SOYnGstKyVv3DXBv0N0KGDXeASwGGgq+6dFPTOtjPkiz5LRqu2nuaHaj3A lXsd1xlTyLGH2PAkE9besb6YzUUl5FcV8kULJD4l4DtJfLbf74TvBGBDXYqglBjkIUUQ jz3Q== X-Gm-Message-State: AOAM532GFpSy/rUSvvF7hmXb3ikcwCrLAGbNV49kBevtqVJn9jmbCzCU /RFONOSU/2d1Img48ZaFeUtWUbQTgarDRw== X-Google-Smtp-Source: ABdhPJwouu+gjQkBSrAS1hSTqqdkqgshPbTW8fvxLX2sQBlMSXHT0zpfJ8fAgiUOHKx1Q0e/f1k8mg== X-Received: by 2002:a1c:7d4d:: with SMTP id y74mr10245973wmc.181.1632315224898; Wed, 22 Sep 2021 05:53:44 -0700 (PDT) Received: from nb01533.pb.local ([2001:1438:4010:2540:40a5:9868:5a83:f3b9]) by smtp.gmail.com with ESMTPSA id j20sm2173685wrb.5.2021.09.22.05.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 05:53:44 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com Subject: [PATCH for-next 5/7] RDMA/rtrs: Introduce destroy_cq helper Date: Wed, 22 Sep 2021 14:53:31 +0200 Message-Id: <20210922125333.351454-6-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922125333.351454-1-haris.iqbal@ionos.com> References: <20210922125333.351454-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The same code snip used twice, to avoid duplicate, replace it with a destroy_cq helper. Signed-off-by: Jack Wang Signed-off-by: Md Haris Iqbal --- drivers/infiniband/ulp/rtrs/rtrs.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs.c b/drivers/infiniband/ulp/rtrs/rtrs.c index ac83cd97f838..37952c8e768c 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs.c @@ -279,6 +279,17 @@ static int create_qp(struct rtrs_con *con, struct ib_pd *pd, return ret; } +static void destroy_cq(struct rtrs_con *con) +{ + if (con->cq) { + if (is_pollqueue(con)) + ib_free_cq(con->cq); + else + ib_cq_pool_put(con->cq, con->nr_cqe); + } + con->cq = NULL; +} + int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, u32 max_send_sge, int cq_vector, int nr_cqe, u32 max_send_wr, u32 max_recv_wr, @@ -293,11 +304,7 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr, max_send_sge); if (err) { - if (is_pollqueue(con)) - ib_free_cq(con->cq); - else - ib_cq_pool_put(con->cq, con->nr_cqe); - con->cq = NULL; + destroy_cq(con); return err; } con->sess = sess; @@ -312,13 +319,7 @@ void rtrs_cq_qp_destroy(struct rtrs_con *con) rdma_destroy_qp(con->cm_id); con->qp = NULL; } - if (con->cq) { - if (is_pollqueue(con)) - ib_free_cq(con->cq); - else - ib_cq_pool_put(con->cq, con->nr_cqe); - con->cq = NULL; - } + destroy_cq(con); } EXPORT_SYMBOL_GPL(rtrs_cq_qp_destroy); From patchwork Wed Sep 22 12:53:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12510589 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18603C433F5 for ; Wed, 22 Sep 2021 12:53:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 028C561178 for ; Wed, 22 Sep 2021 12:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236084AbhIVMzS (ORCPT ); Wed, 22 Sep 2021 08:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236158AbhIVMzR (ORCPT ); Wed, 22 Sep 2021 08:55:17 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C2CDC061766 for ; Wed, 22 Sep 2021 05:53:47 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id d21so6359095wra.12 for ; Wed, 22 Sep 2021 05:53:47 -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=iEwXtwVC0+ySn9BAIWSFhSoxcbAilVScX8tg212FZcI=; b=abzJiOLh+MIYBpuPOMHFQ7RlK/ztxnhXaz9yPA1WO/j3DswO3xaBc5QupkytwuqiAL Z5VBzDU9Ffow0PII8y3rtCHGpk4MQIZ+uM0PYA0SP2vqfibOCaqm9sBZgV3sFD0WF2fk dWh5aVpwox7eAk/mD7KFkyFKcAHoA/wxc4sXLyiKU7RvZcOWDKtFCk7db4MIU5XZvzHd Ot9mvLsTPvq/r0atbr6dlyFtvnm/t+TaYv6/s8iN0YBrm5gOxBRYCCeAw1Ph3cIMW6Fy ugSTuY+SR/zQlXbpKdBLOwG0uobTvEOiT+B3XMHDmfcldafBo/C1ddbIWASg4XP8ptpC 7n5w== 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=iEwXtwVC0+ySn9BAIWSFhSoxcbAilVScX8tg212FZcI=; b=V2gP1C6ufBK38vp+N6e0WHJ6ky8vwaiQ55AymPYL+ku+pUz5Qj3j2sE/Q+kgHnICmh Ywo5CVVnRL35Q/johxeuIB0XPxpezDV3Q0aPHqK1LLSnVBL0QCUnCblYG/CYALdfkFR+ /Y7LeO0caqZcTrJaJUvFlY9aNpAkgpH12kxCJzejtVVwQknsQpmMsNZkUmFBdfRJI0fU t1gggFT4ILyQRPp9TiUB2iVdD2TLmHR4pyk4BlaZzxTSItO23A6W0IzV5Ncg9D1lzD0L GBqN7cxcONrnGNSNUnMi2q3rOC+ytgpqmnNJW1TcDhtupf7KDjLFwwdD6LPL5mrDBZUB y2Ow== X-Gm-Message-State: AOAM533lBNpOWAvB9BOcTS2vs95wEbWEb0JtRJE2BsQtEeQU61meaTEh JZLpof2Rsm0Ud4IFgRCJ6sskirQizt96PA== X-Google-Smtp-Source: ABdhPJwTu1T3cVeGTLsX3xGRJW4chknWoZBzSH/GZ7SHDDkS3vGw2HcARVTyThOiKgegB08KV6fKqQ== X-Received: by 2002:a7b:c144:: with SMTP id z4mr10620724wmi.31.1632315226199; Wed, 22 Sep 2021 05:53:46 -0700 (PDT) Received: from nb01533.pb.local ([2001:1438:4010:2540:40a5:9868:5a83:f3b9]) by smtp.gmail.com with ESMTPSA id j20sm2173685wrb.5.2021.09.22.05.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 05:53:45 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Aleksei Marov Subject: [PATCH for-next 6/7] RDMA/rtrs: Do not allow sessname to contain special symbols / and . Date: Wed, 22 Sep 2021 14:53:32 +0200 Message-Id: <20210922125333.351454-7-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922125333.351454-1-haris.iqbal@ionos.com> References: <20210922125333.351454-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Allowing these characters in sessname can lead to unexpected results, particularly because / is used as a separator between files in a path, and . points to the current directory. Signed-off-by: Md Haris Iqbal Reviewed-by: Gioh Kim Reviewed-by: Aleksei Marov --- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 6 ++++++ drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c index bc8824b4ee0d..15c0077dd27e 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c @@ -2788,6 +2788,12 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops, struct rtrs_clt *clt; int err, i; + if (strchr(sessname, '/') || strchr(sessname, '.')) { + pr_err("sessname cannot contain / and .\n"); + err = -EINVAL; + goto out; + } + clt = alloc_clt(sessname, paths_num, port, pdu_sz, ops->priv, ops->link_ev, reconnect_delay_sec, diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 078a1cbac90c..7df71f8cf149 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -803,6 +803,11 @@ static int process_info_req(struct rtrs_srv_con *con, return err; } + if (strchr(msg->sessname, '/') || strchr(msg->sessname, '.')) { + rtrs_err(s, "sessname cannot contain / and .\n"); + return -EINVAL; + } + if (exist_sessname(sess->srv->ctx, msg->sessname, &sess->srv->paths_uuid)) { rtrs_err(s, "sessname is duplicated: %s\n", msg->sessname); From patchwork Wed Sep 22 12:53:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12510593 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB712C433FE for ; Wed, 22 Sep 2021 12:53:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3ACB61178 for ; Wed, 22 Sep 2021 12:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236097AbhIVMzT (ORCPT ); Wed, 22 Sep 2021 08:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236026AbhIVMzS (ORCPT ); Wed, 22 Sep 2021 08:55:18 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA689C06175F for ; Wed, 22 Sep 2021 05:53:48 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id g16so6546318wrb.3 for ; Wed, 22 Sep 2021 05:53:48 -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=a73u6je9MGQm1bgAVFcJn3E75fZC6Gtx6Eslm1ELbEs=; b=D1U6M3lzdiFdkrXqNAIS8PnGvFJfHlfKBic8458HvI69abqcnH0zADlNAYls3m05G9 pDX2lWkG2nTT6Iq8q2CvqcinnA2phjqhjghyaiUKe/BRzgUIyAftE6DsXbLQQhPjR2wI WfeWp1PX9tt5aEPJy/YVN86WCbh8c44mLWKDTZzOp1nFU+KjtSzjevhK0Vscam8Wh7h1 twtL3V3MNqS7gUc2rNtS0dFRR7tnTgFy9RwZtQ4jucGYbxpoza/dlETl3HSjBt8KiuO3 l9Jk9JVFFjA2n0os/agzYoMeJ0E8NcZhWnW0KUMNi84PFYdgT89HgK5aiKFhVj/wpCa1 AA+g== 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=a73u6je9MGQm1bgAVFcJn3E75fZC6Gtx6Eslm1ELbEs=; b=CaE0ARolgU4ZOPM5W18jJvrNPRRSCpEpmUj1huPN/TceWaBbiRhDHlieFyriMs7OId ieS3bH7VaHB0ilCMIAibsGGlA6VZr8XCDfziP8bUfdwqNTWHXSD6ENR9cz3+bK89UhxT yyei++pqnsRooUDmWYJU1qNjRLSkkChX/Re0P7KxDa0ph0UFFgWdJfqOd8U3U3kf01v9 UEW0iPe78ELJzlmlkhVtT92tGKKN4XkhhSbbXDzpccI+h9SDzM2q3Vk0VWV91hgFdEJY rQEW5RUhC/U3nhxEZ9+my9dVIzW0W8FIwyGbrwiOxtidJa1t8/GWZUsxuGORsWTVutah AVzQ== X-Gm-Message-State: AOAM530iy2FpZzUSEyEmi0sF9RB74zbs7cAJSFTT9h6wixPosUvzUWrI SKANJNVf7reCOQkbYLaggPZN4AvisVkS2A== X-Google-Smtp-Source: ABdhPJwErzFmPowoXWKrW4iI3FbvmeQqSC8NJa3bgC4ZAfoSC0iTp2p0ScNcSGUlo2m2NSKBgOTHMA== X-Received: by 2002:a7b:ce19:: with SMTP id m25mr10088052wmc.152.1632315227327; Wed, 22 Sep 2021 05:53:47 -0700 (PDT) Received: from nb01533.pb.local ([2001:1438:4010:2540:40a5:9868:5a83:f3b9]) by smtp.gmail.com with ESMTPSA id j20sm2173685wrb.5.2021.09.22.05.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 05:53:47 -0700 (PDT) From: Md Haris Iqbal To: linux-rdma@vger.kernel.org Cc: bvanassche@acm.org, leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca, haris.iqbal@ionos.com, jinpu.wang@ionos.com, Gioh Kim , Aleksei Marov Subject: [PATCH for-next 7/7] RDMA/rtrs-clt: Follow "one entry one value" rule for IO migration stats Date: Wed, 22 Sep 2021 14:53:33 +0200 Message-Id: <20210922125333.351454-8-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210922125333.351454-1-haris.iqbal@ionos.com> References: <20210922125333.351454-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org This commit divides the sysfs entry cpu_migration into 2 different entries One for "from cpus" and the other for "to cpus". Signed-off-by: Md Haris Iqbal Reviewed-by: Gioh Kim Reviewed-by: Aleksei Marov --- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 27 +++++++++++++------- drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 11 +++++--- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 3 ++- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c index 61d5e0018392..f7e459fe68be 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c @@ -37,29 +37,38 @@ void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats) s->rdma.failover_cnt++; } -int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, char *buf) +int rtrs_clt_stats_migration_from_cnt_to_str(struct rtrs_clt_stats *stats, char *buf) { struct rtrs_clt_stats_pcpu *s; size_t used; int cpu; - used = sysfs_emit(buf, " "); - for_each_possible_cpu(cpu) - used += sysfs_emit_at(buf, used, " CPU%u", cpu); - - used += sysfs_emit_at(buf, used, "\nfrom:"); + used = 0; for_each_possible_cpu(cpu) { s = per_cpu_ptr(stats->pcpu_stats, cpu); - used += sysfs_emit_at(buf, used, " %d", + used += sysfs_emit_at(buf, used, "%d ", atomic_read(&s->cpu_migr.from)); } - used += sysfs_emit_at(buf, used, "\nto :"); + used += sysfs_emit_at(buf, used, "\n"); + + return used; +} + +int rtrs_clt_stats_migration_to_cnt_to_str(struct rtrs_clt_stats *stats, char *buf) +{ + struct rtrs_clt_stats_pcpu *s; + + size_t used; + int cpu; + + used = 0; for_each_possible_cpu(cpu) { s = per_cpu_ptr(stats->pcpu_stats, cpu); - used += sysfs_emit_at(buf, used, " %d", s->cpu_migr.to); + used += sysfs_emit_at(buf, used, "%d ", s->cpu_migr.to); } + used += sysfs_emit_at(buf, used, "\n"); return used; diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c index 4ee592ccf979..0e69180c3771 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c @@ -296,8 +296,12 @@ static struct kobj_attribute rtrs_clt_remove_path_attr = __ATTR(remove_path, 0644, rtrs_clt_remove_path_show, rtrs_clt_remove_path_store); -STAT_ATTR(struct rtrs_clt_stats, cpu_migration, - rtrs_clt_stats_migration_cnt_to_str, +STAT_ATTR(struct rtrs_clt_stats, cpu_migration_from, + rtrs_clt_stats_migration_from_cnt_to_str, + rtrs_clt_reset_cpu_migr_stats); + +STAT_ATTR(struct rtrs_clt_stats, cpu_migration_to, + rtrs_clt_stats_migration_to_cnt_to_str, rtrs_clt_reset_cpu_migr_stats); STAT_ATTR(struct rtrs_clt_stats, reconnects, @@ -313,7 +317,8 @@ STAT_ATTR(struct rtrs_clt_stats, reset_all, rtrs_clt_reset_all_stats); static struct attribute *rtrs_clt_stats_attrs[] = { - &cpu_migration_attr.attr, + &cpu_migration_from_attr.attr, + &cpu_migration_to_attr.attr, &reconnects_attr.attr, &rdma_attr.attr, &reset_all_attr.attr, diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.h b/drivers/infiniband/ulp/rtrs/rtrs-clt.h index 6d81aae53df4..9afffccff973 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.h +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.h @@ -226,7 +226,8 @@ int rtrs_clt_reset_rdma_lat_distr_stats(struct rtrs_clt_stats *stats, ssize_t rtrs_clt_stats_rdma_lat_distr_to_str(struct rtrs_clt_stats *stats, char *page); int rtrs_clt_reset_cpu_migr_stats(struct rtrs_clt_stats *stats, bool enable); -int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, char *buf); +int rtrs_clt_stats_migration_from_cnt_to_str(struct rtrs_clt_stats *stats, char *buf); +int rtrs_clt_stats_migration_to_cnt_to_str(struct rtrs_clt_stats *stats, char *buf); int rtrs_clt_reset_reconnects_stat(struct rtrs_clt_stats *stats, bool enable); int rtrs_clt_stats_reconnects_to_str(struct rtrs_clt_stats *stats, char *buf); int rtrs_clt_reset_rdma_stats(struct rtrs_clt_stats *stats, bool enable);