Whamcloud - gitweb
LU-17054 lnet: use GFP_KERNEL for alloc w/o spinlock 96/53596/5
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 4 Jan 2024 21:32:13 +0000 (14:32 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 18 Jan 2024 06:17:31 +0000 (06:17 +0000)
Do not use genradix_ptr_alloc(GFP_ATOMIC) when not allocating
under a spinlock in lnet_cpt_of_nid_show_start(), since this
puts unnecessary strain on the atomic memory pools.  This
function grabs mutex_lock(&the_lnet.ln_api_mutex) so the caller
cannot be holding a spinlock at the time.

Fix minor code style issues in this function.

Fixes: 466e25a6a3 ("LU-17054 lnet: Change cpt-of-nid to get result from kernel")
Test-Parameters: trivial testlist=sanity-lnet
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I091959940bffadc380bff9329bb83e8b099ed63f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53596
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/api-ni.c

index aebc11c..1efd0fb 100644 (file)
@@ -4879,21 +4879,23 @@ static int lnet_cpt_of_nid_show_start(struct netlink_callback *cb)
                                }
 
                                lnc = genradix_ptr_alloc(&lgncl->lgncl_lnc_list,
-                                                        lgncl->lgncl_list_count++,
-                                                        GFP_ATOMIC);
+                                                     lgncl->lgncl_list_count++,
+                                                     GFP_KERNEL);
                                if (!lnc) {
                                        NL_SET_ERR_MSG(extack,
-                                                      "failed to allocate NID");
+                                                     "failed to allocate NID");
                                        GOTO(report_err, rc = -ENOMEM);
                                }
 
-                               rc = libcfs_strnid(&lnc->lnc_nid, strim(nidstr));
+                               rc = libcfs_strnid(&lnc->lnc_nid,
+                                                  strim(nidstr));
                                if (rc < 0) {
                                        NL_SET_ERR_MSG(extack, "invalid NID");
                                        GOTO(report_err, rc);
                                }
                                rc = 0;
-                               CDEBUG(D_NET, "nid: %s\n", libcfs_nidstr(&lnc->lnc_nid));
+                               CDEBUG(D_NET, "nid: %s\n",
+                                      libcfs_nidstr(&lnc->lnc_nid));
                        }
                        fallthrough;
                default:
@@ -6957,14 +6959,16 @@ static int lnet_peer_ni_show_start(struct netlink_callback *cb)
                cfs_percpt_for_each(ptable, cpt, the_lnet.ln_peer_tables) {
                        struct lnet_peer *lp;
 
-                       list_for_each_entry(lp, &ptable->pt_peer_list, lp_peer_list) {
+                       list_for_each_entry(lp, &ptable->pt_peer_list,
+                                           lp_peer_list) {
                                struct lnet_processid *lpi;
 
                                lpi = genradix_ptr_alloc(&plist->lgpl_list,
                                                         plist->lgpl_count++,
                                                         GFP_KERNEL);
                                if (!lpi) {
-                                       NL_SET_ERR_MSG(extack, "failed to allocate NID");
+                                       NL_SET_ERR_MSG(extack,
+                                                     "failed to allocate NID");
                                        GOTO(report_err, rc = -ENOMEM);
                                }