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: [PATCH 04/14] staging: lustre: lnet: use kmalloc/kvmalloc in router_proc
Date: Tue, 09 Jan 2018 12:19:38 +1100 [thread overview]
Message-ID: <151546077828.9776.11145434430358194964.stgit@noble> (raw)
In-Reply-To: <151546052331.9776.7408338350463291753.stgit@noble>
The buffers allocated in router_proc are to temporarily
hold strings created for procfs files.
So they do not need to be zeroed and are safe to use
GFP_KERNEL.
So use kmalloc() directly except in two cases where it
isn't trivial to confirm that the size is always small.
In those cases, use kvmalloc().
Signed-off-by: NeilBrown <neilb@suse.com>
---
drivers/staging/lustre/lnet/lnet/router_proc.c | 34 ++++++++++++------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 43038f930ba1..1a71ffebc889 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -95,7 +95,7 @@ static int __proc_lnet_stats(void *data, int write,
if (!ctrs)
return -ENOMEM;
- LIBCFS_ALLOC(tmpstr, tmpsiz);
+ tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
if (!tmpstr) {
kfree(ctrs);
return -ENOMEM;
@@ -118,7 +118,7 @@ static int __proc_lnet_stats(void *data, int write,
rc = cfs_trace_copyout_string(buffer, nob,
tmpstr + pos, "\n");
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kfree(tmpstr);
kfree(ctrs);
return rc;
}
@@ -151,7 +151,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
if (!*lenp)
return 0;
- LIBCFS_ALLOC(tmpstr, tmpsiz);
+ tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
if (!tmpstr)
return -ENOMEM;
@@ -183,7 +183,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
if (ver != LNET_PROC_VERSION(the_lnet.ln_remote_nets_version)) {
lnet_net_unlock(0);
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kfree(tmpstr);
return -ESTALE;
}
@@ -248,7 +248,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
}
}
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kfree(tmpstr);
if (!rc)
*lenp = len;
@@ -275,7 +275,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
if (!*lenp)
return 0;
- LIBCFS_ALLOC(tmpstr, tmpsiz);
+ tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
if (!tmpstr)
return -ENOMEM;
@@ -303,7 +303,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
if (ver != LNET_PROC_VERSION(the_lnet.ln_routers_version)) {
lnet_net_unlock(0);
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kfree(tmpstr);
return -ESTALE;
}
@@ -385,7 +385,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
}
}
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kfree(tmpstr);
if (!rc)
*lenp = len;
@@ -418,7 +418,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
return 0;
}
- LIBCFS_ALLOC(tmpstr, tmpsiz);
+ tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
if (!tmpstr)
return -ENOMEM;
@@ -448,7 +448,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
if (ver != LNET_PROC_VERSION(ptable->pt_version)) {
lnet_net_unlock(cpt);
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kfree(tmpstr);
return -ESTALE;
}
@@ -556,7 +556,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
*ppos = LNET_PROC_POS_MAKE(cpt, ver, hash, hoff);
}
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kfree(tmpstr);
if (!rc)
*lenp = len;
@@ -579,7 +579,7 @@ static int __proc_lnet_buffers(void *data, int write,
/* (4 %d) * 4 * LNET_CPT_NUMBER */
tmpsiz = 64 * (LNET_NRBPOOLS + 1) * LNET_CPT_NUMBER;
- LIBCFS_ALLOC(tmpstr, tmpsiz);
+ tmpstr = kvmalloc(tmpsiz, GFP_KERNEL);
if (!tmpstr)
return -ENOMEM;
@@ -618,7 +618,7 @@ static int __proc_lnet_buffers(void *data, int write,
rc = cfs_trace_copyout_string(buffer, nob,
tmpstr + pos, NULL);
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kvfree(tmpstr);
return rc;
}
@@ -643,7 +643,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
if (!*lenp)
return 0;
- LIBCFS_ALLOC(tmpstr, tmpsiz);
+ tmpstr = kvmalloc(tmpsiz, GFP_KERNEL);
if (!tmpstr)
return -ENOMEM;
@@ -744,7 +744,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
*ppos += 1;
}
- LIBCFS_FREE(tmpstr, tmpsiz);
+ kvfree(tmpstr);
if (!rc)
*lenp = len;
@@ -795,7 +795,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,
int rc;
int i;
- LIBCFS_ALLOC(buf, buf_len);
+ buf = kmalloc(buf_len, GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -843,7 +843,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,
}
lnet_res_unlock(0);
out:
- LIBCFS_FREE(buf, buf_len);
+ kfree(buf);
return rc;
}
next prev parent reply other threads:[~2018-01-09 1:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-09 1:19 [PATCH 00/14] staging:lustre: convert most LIBCFS*ALLOC to k*malloc - V2 NeilBrown
2018-01-09 1:19 ` [PATCH 05/14] staging: lustre: change some LIBCFS_ALLOC calls to k?alloc(GFP_KERNEL) NeilBrown
2018-01-09 1:19 ` [PATCH 10/14] staging: lustre: use kmalloc for allocating ksock_tx NeilBrown
2018-01-09 1:19 ` [PATCH 06/14] staging: lustre: Convert more LIBCFS_ALLOC allocation to direct GFP_KERNEL NeilBrown
2018-01-09 1:19 ` [PATCH 07/14] staging: lustre: more LIBCFS_ALLOC conversions to GFP_KERNEL allocations NeilBrown
2018-01-09 1:19 ` [PATCH 08/14] staging: lustre: more " NeilBrown
2018-01-09 1:19 ` [PATCH 12/14] staging: lustre: opencode LIBCFS_ALLOC_ATOMIC calls NeilBrown
2018-01-09 1:19 ` [PATCH 03/14] staging: lustre: lnet: selftest: don't allocate small strings NeilBrown
2018-01-09 1:19 ` NeilBrown [this message]
2018-01-09 1:19 ` [PATCH 01/14] staging: lustre: replace simple cases of LIBCFS_ALLOC with kzalloc NeilBrown
2018-01-09 1:19 ` [PATCH 02/14] staging: lustre: lnet: switch to cpumask_var_t NeilBrown
2018-01-09 1:19 ` [PATCH 14/14] staging: lustre: remove LIBCFS_ALLOC, LIBCFS_FREE and related macros NeilBrown
2018-01-09 1:19 ` [PATCH 13/14] staging: lustre: replace LIBCFS_CPT_ALLOC() NeilBrown
2018-01-09 1:19 ` [PATCH 11/14] staging: lustre: cfs_percpt_alloc: use kvmalloc(GFP_KERNEL) NeilBrown
2018-01-09 1:19 ` [PATCH 09/14] staging: lustre: lnet-route: use kmalloc for small allocation NeilBrown
2018-01-09 15:00 ` [PATCH 00/14] staging:lustre: convert most LIBCFS*ALLOC to k*malloc - V2 Greg Kroah-Hartman
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=151546077828.9776.11145434430358194964.stgit@noble \
--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®