From: NeilBrown <neilb@suse.com>
To: Oleg Drokin <oleg.drokin@intel.com>,
Andreas Dilger <andreas.dilger@intel.com>,
James Simmons <jsimmons@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
lustre <lustre-devel@lists.lustre.org>
Subject: Re: [lustre-devel] [PATCH 08/15] staging: lustre: Convert more LIBCFS_ALLOC allocation to direct GFP_KERNEL
Date: Mon, 18 Dec 2017 18:13:13 +1100 [thread overview]
Message-ID: <87y3m0ld9y.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <151355799049.6200.16488920506903028598.stgit@noble>
[-- Attachment #1: Type: text/plain, Size: 8427 bytes --]
Sorry, it seems I mustn't have tested the file version of this
patch. That "kvmalloc_node()" was clearly wrong.
This version passes testing.
Thanks,
NeilBrown
"git am" will ignore everything before this line:
-----------------8<-----------------
None of these need to be GFP_NOFS, so use GFP_KERNEL explicitly
with kmalloc(), kvmalloc(), or kvmalloc_array().
Changing matching LIBCFS_FREE() to kfree() or kvfree()
Signed-off-by: NeilBrown <neilb@suse.com>
---
.../lustre/lnet/libcfs/linux/linux-module.c | 4 +--
drivers/staging/lustre/lnet/libcfs/module.c | 9 +++---
drivers/staging/lustre/lnet/lnet/api-ni.c | 17 +++++------
drivers/staging/lustre/lnet/lnet/config.c | 34 +++++++++-------------
4 files changed, 26 insertions(+), 38 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index b5746230ab31..ddf625669bff 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -146,7 +146,7 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
return -EINVAL;
}
- LIBCFS_ALLOC(*hdr_pp, hdr.ioc_len);
+ *hdr_pp = kvmalloc(hdr.ioc_len, GFP_KERNEL);
if (!*hdr_pp)
return -ENOMEM;
@@ -164,7 +164,7 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
return 0;
free:
- LIBCFS_FREE(*hdr_pp, hdr.ioc_len);
+ kvfree(*hdr_pp);
return err;
}
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index 4ead55920e79..1bd33497a7c0 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -156,7 +156,7 @@ int libcfs_ioctl(unsigned long cmd, void __user *uparam)
break; }
}
out:
- LIBCFS_FREE(hdr, hdr->ioc_len);
+ kvfree(hdr);
return err;
}
@@ -302,7 +302,7 @@ static int __proc_cpt_table(void *data, int write,
LASSERT(cfs_cpt_table);
while (1) {
- LIBCFS_ALLOC(buf, len);
+ buf = kzalloc(len, GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -311,7 +311,7 @@ static int __proc_cpt_table(void *data, int write,
break;
if (rc == -EFBIG) {
- LIBCFS_FREE(buf, len);
+ kfree(buf);
len <<= 1;
continue;
}
@@ -325,8 +325,7 @@ static int __proc_cpt_table(void *data, int write,
rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL);
out:
- if (buf)
- LIBCFS_FREE(buf, len);
+ kfree(buf);
return rc;
}
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index e8f623190133..6a1fb0397604 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -108,7 +108,8 @@ lnet_create_remote_nets_table(void)
LASSERT(!the_lnet.ln_remote_nets_hash);
LASSERT(the_lnet.ln_remote_nets_hbits > 0);
- LIBCFS_ALLOC(hash, LNET_REMOTE_NETS_HASH_SIZE * sizeof(*hash));
+ hash = kvmalloc_array(LNET_REMOTE_NETS_HASH_SIZE, sizeof(*hash),
+ GFP_KERNEL);
if (!hash) {
CERROR("Failed to create remote nets hash table\n");
return -ENOMEM;
@@ -131,9 +132,7 @@ lnet_destroy_remote_nets_table(void)
for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++)
LASSERT(list_empty(&the_lnet.ln_remote_nets_hash[i]));
- LIBCFS_FREE(the_lnet.ln_remote_nets_hash,
- LNET_REMOTE_NETS_HASH_SIZE *
- sizeof(the_lnet.ln_remote_nets_hash[0]));
+ kvfree(the_lnet.ln_remote_nets_hash);
the_lnet.ln_remote_nets_hash = NULL;
}
@@ -831,7 +830,7 @@ lnet_ping_info_create(int num_ni)
unsigned int infosz;
infosz = offsetof(struct lnet_ping_info, pi_ni[num_ni]);
- LIBCFS_ALLOC(ping_info, infosz);
+ ping_info = kvzalloc(infosz, GFP_KERNEL);
if (!ping_info) {
CERROR("Can't allocate ping info[%d]\n", num_ni);
return NULL;
@@ -864,9 +863,7 @@ lnet_get_ni_count(void)
static inline void
lnet_ping_info_free(struct lnet_ping_info *pinfo)
{
- LIBCFS_FREE(pinfo,
- offsetof(struct lnet_ping_info,
- pi_ni[pinfo->pi_nnis]));
+ kvfree(pinfo);
}
static void
@@ -2160,7 +2157,7 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,
if (id.pid == LNET_PID_ANY)
id.pid = LNET_PID_LUSTRE;
- LIBCFS_ALLOC(info, infosz);
+ info = kzalloc(infosz, GFP_KERNEL);
if (!info)
return -ENOMEM;
@@ -2310,6 +2307,6 @@ static int lnet_ping(struct lnet_process_id id, int timeout_ms,
LASSERT(!rc2);
out_0:
- LIBCFS_FREE(info, infosz);
+ kfree(info);
return rc;
}
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 66a222e5220b..fd53c74766a7 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -109,10 +109,8 @@ lnet_ni_free(struct lnet_ni *ni)
if (ni->ni_lnd_tunables)
kfree(ni->ni_lnd_tunables);
- for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++) {
- LIBCFS_FREE(ni->ni_interfaces[i],
- strlen(ni->ni_interfaces[i]) + 1);
- }
+ for (i = 0; i < LNET_MAX_INTERFACES && ni->ni_interfaces[i]; i++)
+ kfree(ni->ni_interfaces[i]);
/* release reference to net namespace */
if (ni->ni_net_ns)
@@ -198,7 +196,6 @@ int
lnet_parse_networks(struct list_head *nilist, char *networks)
{
struct cfs_expr_list *el = NULL;
- int tokensize;
char *tokens;
char *str;
char *tmp;
@@ -219,15 +216,12 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
return -EINVAL;
}
- tokensize = strlen(networks) + 1;
-
- LIBCFS_ALLOC(tokens, tokensize);
+ tokens = kstrdup(networks, GFP_KERNEL);
if (!tokens) {
CERROR("Can't allocate net tokens\n");
return -ENOMEM;
}
- memcpy(tokens, networks, tokensize);
tmp = tokens;
str = tokens;
@@ -349,14 +343,11 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
* The newly allocated ni_interfaces[] can be
* freed when freeing the NI
*/
- LIBCFS_ALLOC(ni->ni_interfaces[niface],
- strlen(iface) + 1);
+ ni->ni_interfaces[niface] = kstrdup(iface, GFP_KERNEL);
if (!ni->ni_interfaces[niface]) {
CERROR("Can't allocate net interface name\n");
goto failed;
}
- strncpy(ni->ni_interfaces[niface], iface,
- strlen(iface));
niface++;
iface = comma;
} while (iface);
@@ -384,7 +375,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
list_for_each(temp_node, nilist)
nnets++;
- LIBCFS_FREE(tokens, tokensize);
+ kfree(tokens);
return nnets;
failed_syntax:
@@ -400,7 +391,7 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
if (el)
cfs_expr_list_free(el);
- LIBCFS_FREE(tokens, tokensize);
+ kfree(tokens);
return -EINVAL;
}
@@ -424,7 +415,7 @@ lnet_new_text_buf(int str_len)
return NULL;
}
- LIBCFS_ALLOC(ltb, nob);
+ ltb = kzalloc(nob, GFP_KERNEL);
if (!ltb)
return NULL;
@@ -438,7 +429,7 @@ static void
lnet_free_text_buf(struct lnet_text_buf *ltb)
{
lnet_tbnob -= ltb->ltb_size;
- LIBCFS_FREE(ltb, ltb->ltb_size);
+ kfree(ltb);
}
static void
@@ -1156,7 +1147,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
if (nif <= 0)
return nif;
- LIBCFS_ALLOC(ipaddrs, nif * sizeof(*ipaddrs));
+ ipaddrs = kzalloc(nif * sizeof(*ipaddrs), GFP_KERNEL);
if (!ipaddrs) {
CERROR("Can't allocate ipaddrs[%d]\n", nif);
lnet_ipif_free_enumeration(ifnames, nif);
@@ -1189,7 +1180,8 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
*ipaddrsp = ipaddrs;
} else {
if (nip > 0) {
- LIBCFS_ALLOC(ipaddrs2, nip * sizeof(*ipaddrs2));
+ ipaddrs2 = kzalloc(nip * sizeof(*ipaddrs2),
+ GFP_KERNEL);
if (!ipaddrs2) {
CERROR("Can't allocate ipaddrs[%d]\n", nip);
nip = -ENOMEM;
@@ -1200,7 +1192,7 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
rc = nip;
}
}
- LIBCFS_FREE(ipaddrs, nip * sizeof(*ipaddrs));
+ kfree(ipaddrs);
}
return nip;
}
@@ -1226,7 +1218,7 @@ lnet_parse_ip2nets(char **networksp, char *ip2nets)
}
rc = lnet_match_networks(networksp, ip2nets, ipaddrs, nip);
- LIBCFS_FREE(ipaddrs, nip * sizeof(*ipaddrs));
+ kfree(ipaddrs);
if (rc < 0) {
LCONSOLE_ERROR_MSG(0x119, "Error %d parsing ip2nets\n", rc);
--
2.14.0.rc0.dirty
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
prev parent reply other threads:[~2017-12-18 7:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-18 0:46 [PATCH SERIES 1: 00/15] staging:lustre: convert most LIBCFS*ALLOC to k*malloc NeilBrown
2017-12-18 0:46 ` [PATCH 12/15] staging: lustre: use kmalloc for allocating ksock_tx NeilBrown
2017-12-18 0:46 ` [PATCH 04/15] staging: lustre: lnet: switch to cpumask_var_t NeilBrown
2017-12-18 0:46 ` [PATCH 07/15] staging: lustre: change some LIBCFS_ALLOC calls to k?alloc(GFP_KERNEL) NeilBrown
2017-12-18 0:46 ` [PATCH 05/15] staging: lustre: lnet: selftest: don't allocate small strings NeilBrown
2017-12-18 0:46 ` [PATCH 09/15] staging: lustre: more LIBCFS_ALLOC conversions to GFP_KERNEL allocations NeilBrown
2017-12-18 0:46 ` [PATCH 02/15] staging: lustre: lnet: discard CFS_ALLOC_PTR NeilBrown
2017-12-18 0:46 ` [PATCH 10/15] staging: lustre: more conversions to GFP_KERNEL allocations NeilBrown
2017-12-18 0:46 ` [PATCH 01/15] staging: lustre: lnet-lib: opencode some alloc/free functions NeilBrown
2017-12-18 0:46 ` [PATCH 15/15] staging: lustre: remove LIBCFS_ALLOC and LIBCFS_ALLOC_ATOMIC NeilBrown
2017-12-18 0:46 ` [PATCH 13/15] staging: lustre: cfs_percpt_alloc: use kvmalloc(GFP_KERNEL) NeilBrown
2017-12-18 0:46 ` [PATCH 11/15] staging: lustre: lnet-route: use kmalloc for small allocation NeilBrown
2017-12-18 0:46 ` [PATCH 14/15] staging: lustre: opencode LIBCFS_ALLOC_ATOMIC calls NeilBrown
2017-12-18 0:46 ` [PATCH 06/15] staging: lustre: lnet: use kmalloc/kvmalloc in router_proc NeilBrown
2017-12-18 0:46 ` [PATCH 03/15] staging: lustre: replace simple cases of LIBCFS_ALLOC with kzalloc NeilBrown
2017-12-20 4:12 ` kbuild test robot
2017-12-20 7:14 ` kbuild test robot
2017-12-21 9:40 ` kbuild test robot
2017-12-21 9:40 ` [PATCH] staging: lustre: fix ifnullfree.cocci warnings kbuild test robot
2018-01-08 14:51 ` [PATCH 03/15] staging: lustre: replace simple cases of LIBCFS_ALLOC with kzalloc Greg Kroah-Hartman
2018-01-08 21:39 ` NeilBrown
2017-12-18 0:46 ` [PATCH 08/15] staging: lustre: Convert more LIBCFS_ALLOC allocation to direct GFP_KERNEL NeilBrown
2017-12-18 7:13 ` NeilBrown [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y3m0ld9y.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=andreas.dilger@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®