net/sunrpc/svc.c
Source file repositories/reference/linux-study-clean/net/sunrpc/svc.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/svc.c- Extension
.c- Size
- 46308 bytes
- Lines
- 1847
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/linkage.hlinux/sched/signal.hlinux/errno.hlinux/net.hlinux/in.hlinux/mm.hlinux/interrupt.hlinux/module.hlinux/kthread.hlinux/slab.hlinux/sunrpc/types.hlinux/sunrpc/xdr.hlinux/sunrpc/stats.hlinux/sunrpc/svcsock.hlinux/sunrpc/clnt.hlinux/sunrpc/bc_xprt.htrace/events/sunrpc.hfail.hsunrpc.h
Detected Declarations
struct svc_pool_mapfunction __param_set_pool_modefunction param_set_pool_modefunction sunrpc_set_pool_modefunction sunrpc_get_pool_modefunction param_get_pool_modefunction svc_pool_map_choose_modefunction svc_pool_map_alloc_arraysfunction svc_pool_map_init_percpufunction for_each_online_cpufunction svc_pool_map_init_pernodefunction for_each_node_with_cpusfunction poolsfunction svc_pool_map_putfunction svc_pool_map_get_nodefunction svc_pool_map_set_cpumaskfunction svc_rpcb_setupfunction svc_rpcb_cleanupfunction svc_uses_rpcbindfunction svc_bindfunction __svc_init_bcfunction __svc_init_bcfunction intfunction intfunction svc_destroyfunction svc_init_bufferfunction svc_release_bufferfunction svc_rqst_freefunction svc_prepare_threadfunction svc_pool_wake_idle_threadfunction svc_new_threadfunction svc_start_kthreadsfunction svc_stop_kthreadsfunction svc_set_pool_threadsfunction svc_set_num_threadsfunction svc_rqst_replace_pagefunction svc_rqst_release_pagesfunction svc_new_threadfunction __svc_rpcb_register4function __svc_rpcb_register6function __svc_registerfunction svc_rpcbind_set_versionfunction svc_generic_rpcbind_setfunction svc_registerfunction __svc_unregisterfunction databasefunction __printffunction __printf
Annotated Snippet
struct svc_pool_map {
int count; /* How many svc_servs use us */
int mode; /* Note: int not enum to avoid
* warnings about "enumeration value
* not handled in switch" */
unsigned int npools;
unsigned int *pool_to; /* maps pool id to cpu or node */
unsigned int *to_pool; /* maps cpu or node to pool id */
};
static struct svc_pool_map svc_pool_map = {
.mode = SVC_POOL_DEFAULT
};
static DEFINE_MUTEX(svc_pool_map_mutex);/* protects svc_pool_map.count only */
static int
__param_set_pool_mode(const char *val, struct svc_pool_map *m)
{
int err, mode;
mutex_lock(&svc_pool_map_mutex);
err = 0;
if (!strncmp(val, "auto", 4))
mode = SVC_POOL_AUTO;
else if (!strncmp(val, "global", 6))
mode = SVC_POOL_GLOBAL;
else if (!strncmp(val, "percpu", 6))
mode = SVC_POOL_PERCPU;
else if (!strncmp(val, "pernode", 7))
mode = SVC_POOL_PERNODE;
else
err = -EINVAL;
if (err)
goto out;
if (m->count == 0)
m->mode = mode;
else if (mode != m->mode)
err = -EBUSY;
out:
mutex_unlock(&svc_pool_map_mutex);
return err;
}
static int
param_set_pool_mode(const char *val, const struct kernel_param *kp)
{
struct svc_pool_map *m = kp->arg;
return __param_set_pool_mode(val, m);
}
int sunrpc_set_pool_mode(const char *val)
{
return __param_set_pool_mode(val, &svc_pool_map);
}
EXPORT_SYMBOL(sunrpc_set_pool_mode);
/**
* sunrpc_get_pool_mode - get the current pool_mode for the host
* @buf: where to write the current pool_mode
* @size: size of @buf
*
* Grab the current pool_mode from the svc_pool_map and write
* the resulting string to @buf. Returns the number of characters
* written to @buf (a'la snprintf()).
*/
int
sunrpc_get_pool_mode(char *buf, size_t size)
{
struct svc_pool_map *m = &svc_pool_map;
switch (m->mode)
{
case SVC_POOL_AUTO:
return snprintf(buf, size, "auto");
case SVC_POOL_GLOBAL:
return snprintf(buf, size, "global");
case SVC_POOL_PERCPU:
return snprintf(buf, size, "percpu");
case SVC_POOL_PERNODE:
return snprintf(buf, size, "pernode");
default:
return snprintf(buf, size, "%d", m->mode);
}
}
EXPORT_SYMBOL(sunrpc_get_pool_mode);
Annotation
- Immediate include surface: `linux/linkage.h`, `linux/sched/signal.h`, `linux/errno.h`, `linux/net.h`, `linux/in.h`, `linux/mm.h`, `linux/interrupt.h`, `linux/module.h`.
- Detected declarations: `struct svc_pool_map`, `function __param_set_pool_mode`, `function param_set_pool_mode`, `function sunrpc_set_pool_mode`, `function sunrpc_get_pool_mode`, `function param_get_pool_mode`, `function svc_pool_map_choose_mode`, `function svc_pool_map_alloc_arrays`, `function svc_pool_map_init_percpu`, `function for_each_online_cpu`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.