2007-12-13 06:13:19 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the BSD-type
|
|
|
|
* license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
*
|
|
|
|
* Neither the name of the Network Appliance, Inc. nor the names of
|
|
|
|
* its contributors may be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Author: Tom Tucker <tom@opengridcomputing.com>
|
|
|
|
*/
|
2015-06-04 23:21:42 +08:00
|
|
|
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2007-12-13 06:13:19 +08:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/sysctl.h>
|
2010-10-15 23:49:27 +08:00
|
|
|
#include <linux/workqueue.h>
|
2007-12-13 06:13:19 +08:00
|
|
|
#include <linux/sunrpc/clnt.h>
|
|
|
|
#include <linux/sunrpc/sched.h>
|
|
|
|
#include <linux/sunrpc/svc_rdma.h>
|
2012-02-16 01:30:00 +08:00
|
|
|
#include "xprt_rdma.h"
|
2007-12-13 06:13:19 +08:00
|
|
|
|
|
|
|
#define RPCDBG_FACILITY RPCDBG_SVCXPRT
|
|
|
|
|
|
|
|
/* RPC/RDMA parameters */
|
|
|
|
unsigned int svcrdma_ord = RPCRDMA_ORD;
|
|
|
|
static unsigned int min_ord = 1;
|
|
|
|
static unsigned int max_ord = 4096;
|
|
|
|
unsigned int svcrdma_max_requests = RPCRDMA_MAX_REQUESTS;
|
2016-01-08 03:50:02 +08:00
|
|
|
unsigned int svcrdma_max_bc_requests = RPCRDMA_MAX_BC_REQUESTS;
|
2007-12-13 06:13:19 +08:00
|
|
|
static unsigned int min_max_requests = 4;
|
|
|
|
static unsigned int max_max_requests = 16384;
|
|
|
|
unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
|
|
|
|
static unsigned int min_max_inline = 4096;
|
|
|
|
static unsigned int max_max_inline = 65536;
|
|
|
|
|
|
|
|
atomic_t rdma_stat_recv;
|
|
|
|
atomic_t rdma_stat_read;
|
|
|
|
atomic_t rdma_stat_write;
|
|
|
|
atomic_t rdma_stat_sq_starve;
|
|
|
|
atomic_t rdma_stat_rq_starve;
|
|
|
|
atomic_t rdma_stat_rq_poll;
|
|
|
|
atomic_t rdma_stat_rq_prod;
|
|
|
|
atomic_t rdma_stat_sq_poll;
|
|
|
|
atomic_t rdma_stat_sq_prod;
|
|
|
|
|
2010-10-15 23:49:27 +08:00
|
|
|
struct workqueue_struct *svc_rdma_wq;
|
|
|
|
|
2007-12-13 06:13:19 +08:00
|
|
|
/*
|
|
|
|
* This function implements reading and resetting an atomic_t stat
|
|
|
|
* variable through read/write to a proc file. Any write to the file
|
|
|
|
* resets the associated statistic to zero. Any read returns it's
|
|
|
|
* current value.
|
|
|
|
*/
|
2013-06-12 14:04:25 +08:00
|
|
|
static int read_reset_stat(struct ctl_table *table, int write,
|
2009-09-24 06:57:19 +08:00
|
|
|
void __user *buffer, size_t *lenp,
|
2007-12-13 06:13:19 +08:00
|
|
|
loff_t *ppos)
|
|
|
|
{
|
|
|
|
atomic_t *stat = (atomic_t *)table->data;
|
|
|
|
|
|
|
|
if (!stat)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (write)
|
|
|
|
atomic_set(stat, 0);
|
|
|
|
else {
|
|
|
|
char str_buf[32];
|
|
|
|
char *data;
|
|
|
|
int len = snprintf(str_buf, 32, "%d\n", atomic_read(stat));
|
|
|
|
if (len >= 32)
|
|
|
|
return -EFAULT;
|
|
|
|
len = strlen(str_buf);
|
|
|
|
if (*ppos > len) {
|
|
|
|
*lenp = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
data = &str_buf[*ppos];
|
|
|
|
len -= *ppos;
|
|
|
|
if (len > *lenp)
|
|
|
|
len = *lenp;
|
|
|
|
if (len && copy_to_user(buffer, str_buf, len))
|
|
|
|
return -EFAULT;
|
|
|
|
*lenp = len;
|
|
|
|
*ppos += len;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ctl_table_header *svcrdma_table_header;
|
2013-06-12 14:04:25 +08:00
|
|
|
static struct ctl_table svcrdma_parm_table[] = {
|
2007-12-13 06:13:19 +08:00
|
|
|
{
|
|
|
|
.procname = "max_requests",
|
|
|
|
.data = &svcrdma_max_requests,
|
|
|
|
.maxlen = sizeof(unsigned int),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
2007-12-13 06:13:19 +08:00
|
|
|
.extra1 = &min_max_requests,
|
|
|
|
.extra2 = &max_max_requests
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "max_req_size",
|
|
|
|
.data = &svcrdma_max_req_size,
|
|
|
|
.maxlen = sizeof(unsigned int),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
2007-12-13 06:13:19 +08:00
|
|
|
.extra1 = &min_max_inline,
|
|
|
|
.extra2 = &max_max_inline
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "max_outbound_read_requests",
|
|
|
|
.data = &svcrdma_ord,
|
|
|
|
.maxlen = sizeof(unsigned int),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
2007-12-13 06:13:19 +08:00
|
|
|
.extra1 = &min_ord,
|
|
|
|
.extra2 = &max_ord,
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_read",
|
|
|
|
.data = &rdma_stat_read,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_recv",
|
|
|
|
.data = &rdma_stat_recv,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_write",
|
|
|
|
.data = &rdma_stat_write,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_sq_starve",
|
|
|
|
.data = &rdma_stat_sq_starve,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_rq_starve",
|
|
|
|
.data = &rdma_stat_rq_starve,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_rq_poll",
|
|
|
|
.data = &rdma_stat_rq_poll,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_rq_prod",
|
|
|
|
.data = &rdma_stat_rq_prod,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_sq_poll",
|
|
|
|
.data = &rdma_stat_sq_poll,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "rdma_stat_sq_prod",
|
|
|
|
.data = &rdma_stat_sq_prod,
|
|
|
|
.maxlen = sizeof(atomic_t),
|
|
|
|
.mode = 0644,
|
2009-11-16 19:11:48 +08:00
|
|
|
.proc_handler = read_reset_stat,
|
2007-12-13 06:13:19 +08:00
|
|
|
},
|
2009-11-06 05:32:03 +08:00
|
|
|
{ },
|
2007-12-13 06:13:19 +08:00
|
|
|
};
|
|
|
|
|
2013-06-12 14:04:25 +08:00
|
|
|
static struct ctl_table svcrdma_table[] = {
|
2007-12-13 06:13:19 +08:00
|
|
|
{
|
|
|
|
.procname = "svc_rdma",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = svcrdma_parm_table
|
|
|
|
},
|
2009-11-06 05:32:03 +08:00
|
|
|
{ },
|
2007-12-13 06:13:19 +08:00
|
|
|
};
|
|
|
|
|
2013-06-12 14:04:25 +08:00
|
|
|
static struct ctl_table svcrdma_root_table[] = {
|
2007-12-13 06:13:19 +08:00
|
|
|
{
|
|
|
|
.procname = "sunrpc",
|
|
|
|
.mode = 0555,
|
|
|
|
.child = svcrdma_table
|
|
|
|
},
|
2009-11-06 05:32:03 +08:00
|
|
|
{ },
|
2007-12-13 06:13:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void svc_rdma_cleanup(void)
|
|
|
|
{
|
|
|
|
dprintk("SVCRDMA Module Removed, deregister RPC RDMA transport\n");
|
2010-10-15 23:49:27 +08:00
|
|
|
destroy_workqueue(svc_rdma_wq);
|
2007-12-13 06:13:19 +08:00
|
|
|
if (svcrdma_table_header) {
|
|
|
|
unregister_sysctl_table(svcrdma_table_header);
|
|
|
|
svcrdma_table_header = NULL;
|
|
|
|
}
|
2015-10-25 05:28:16 +08:00
|
|
|
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
|
|
|
|
svc_unreg_xprt_class(&svc_rdma_bc_class);
|
|
|
|
#endif
|
2007-12-13 06:13:19 +08:00
|
|
|
svc_unreg_xprt_class(&svc_rdma_class);
|
|
|
|
}
|
|
|
|
|
|
|
|
int svc_rdma_init(void)
|
|
|
|
{
|
|
|
|
dprintk("SVCRDMA Module Init, register RPC RDMA transport\n");
|
|
|
|
dprintk("\tsvcrdma_ord : %d\n", svcrdma_ord);
|
2016-01-08 03:50:02 +08:00
|
|
|
dprintk("\tmax_requests : %u\n", svcrdma_max_requests);
|
|
|
|
dprintk("\tsq_depth : %u\n",
|
2007-12-13 06:13:19 +08:00
|
|
|
svcrdma_max_requests * RPCRDMA_SQ_DEPTH_MULT);
|
2016-01-08 03:50:02 +08:00
|
|
|
dprintk("\tmax_bc_requests : %u\n", svcrdma_max_bc_requests);
|
2007-12-13 06:13:19 +08:00
|
|
|
dprintk("\tmax_inline : %d\n", svcrdma_max_req_size);
|
2010-10-15 23:49:27 +08:00
|
|
|
|
|
|
|
svc_rdma_wq = alloc_workqueue("svc_rdma", 0, 0);
|
|
|
|
if (!svc_rdma_wq)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-12-13 06:13:19 +08:00
|
|
|
if (!svcrdma_table_header)
|
|
|
|
svcrdma_table_header =
|
|
|
|
register_sysctl_table(svcrdma_root_table);
|
|
|
|
|
|
|
|
/* Register RDMA with the SVC transport switch */
|
|
|
|
svc_reg_xprt_class(&svc_rdma_class);
|
2015-10-25 05:28:16 +08:00
|
|
|
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
|
|
|
|
svc_reg_xprt_class(&svc_rdma_bc_class);
|
|
|
|
#endif
|
2007-12-13 06:13:19 +08:00
|
|
|
return 0;
|
|
|
|
}
|