From 9c1deba3846437268f2053860bafed2cd6a9b791 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 4 Jan 2024 14:32:13 -0700 Subject: [PATCH] LU-17054 lnet: use GFP_KERNEL for alloc w/o spinlock 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 Change-Id: I091959940bffadc380bff9329bb83e8b099ed63f Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53596 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Chris Horn Reviewed-by: Cyril Bordage Reviewed-by: Oleg Drokin --- lnet/lnet/api-ni.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index aebc11c..1efd0fb 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -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); } -- 1.8.3.1