Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd/sunrpc: move pool_mode definitions into svc.h

In later patches, we're going to need to allow code external to svc.c
to figure out what pool_mode is in use. Move these definitions into
svc.h to prepare for that.

Also, make the svc_pool_map object available and exported so that other
modules can peek in there to get insight into what pool mode is in use.
Likewise, export svc_pool_map_get/put function to make it safe to do so.

Signed-off-by: Shirley Ma <shirley.ma@oracle.com>
Acked-by: Jeff Layton <jlayton@primarydata.com>
Tested-by: Shirley Ma <shirley.ma@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Jeff Layton and committed by
J. Bruce Fields
d70bc0c6 598e2359

+32 -24
+25
include/linux/sunrpc/svc.h
··· 428 428 }; 429 429 430 430 /* 431 + * Mode for mapping cpus to pools. 432 + */ 433 + enum { 434 + SVC_POOL_AUTO = -1, /* choose one of the others */ 435 + SVC_POOL_GLOBAL, /* no mapping, just a single global pool 436 + * (legacy & UP mode) */ 437 + SVC_POOL_PERCPU, /* one pool per cpu */ 438 + SVC_POOL_PERNODE /* one pool per numa node */ 439 + }; 440 + 441 + struct svc_pool_map { 442 + int count; /* How many svc_servs use us */ 443 + int mode; /* Note: int not enum to avoid 444 + * warnings about "enumeration value 445 + * not handled in switch" */ 446 + unsigned int npools; 447 + unsigned int *pool_to; /* maps pool id to cpu or node */ 448 + unsigned int *to_pool; /* maps cpu or node to pool id */ 449 + }; 450 + 451 + extern struct svc_pool_map svc_pool_map; 452 + 453 + /* 431 454 * Function prototypes. 432 455 */ 433 456 int svc_rpcb_setup(struct svc_serv *serv, struct net *net); ··· 461 438 struct svc_rqst *svc_prepare_thread(struct svc_serv *serv, 462 439 struct svc_pool *pool, int node); 463 440 void svc_exit_thread(struct svc_rqst *); 441 + unsigned int svc_pool_map_get(void); 442 + void svc_pool_map_put(void); 464 443 struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, 465 444 struct svc_serv_ops *); 466 445 int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);
+7 -24
net/sunrpc/svc.c
··· 36 36 37 37 #define svc_serv_is_pooled(serv) ((serv)->sv_ops->svo_function) 38 38 39 - /* 40 - * Mode for mapping cpus to pools. 41 - */ 42 - enum { 43 - SVC_POOL_AUTO = -1, /* choose one of the others */ 44 - SVC_POOL_GLOBAL, /* no mapping, just a single global pool 45 - * (legacy & UP mode) */ 46 - SVC_POOL_PERCPU, /* one pool per cpu */ 47 - SVC_POOL_PERNODE /* one pool per numa node */ 48 - }; 49 39 #define SVC_POOL_DEFAULT SVC_POOL_GLOBAL 50 40 51 41 /* 52 42 * Structure for mapping cpus to pools and vice versa. 53 43 * Setup once during sunrpc initialisation. 54 44 */ 55 - static struct svc_pool_map { 56 - int count; /* How many svc_servs use us */ 57 - int mode; /* Note: int not enum to avoid 58 - * warnings about "enumeration value 59 - * not handled in switch" */ 60 - unsigned int npools; 61 - unsigned int *pool_to; /* maps pool id to cpu or node */ 62 - unsigned int *to_pool; /* maps cpu or node to pool id */ 63 - } svc_pool_map = { 64 - .count = 0, 45 + struct svc_pool_map svc_pool_map = { 65 46 .mode = SVC_POOL_DEFAULT 66 47 }; 48 + EXPORT_SYMBOL_GPL(svc_pool_map); 49 + 67 50 static DEFINE_MUTEX(svc_pool_map_mutex);/* protects svc_pool_map.count only */ 68 51 69 52 static int ··· 219 236 * vice versa). Initialise the map if we're the first user. 220 237 * Returns the number of pools. 221 238 */ 222 - static unsigned int 239 + unsigned int 223 240 svc_pool_map_get(void) 224 241 { 225 242 struct svc_pool_map *m = &svc_pool_map; ··· 254 271 mutex_unlock(&svc_pool_map_mutex); 255 272 return m->npools; 256 273 } 257 - 274 + EXPORT_SYMBOL_GPL(svc_pool_map_get); 258 275 259 276 /* 260 277 * Drop a reference to the global map of cpus to pools. ··· 263 280 * mode using the pool_mode module option without 264 281 * rebooting or re-loading sunrpc.ko. 265 282 */ 266 - static void 283 + void 267 284 svc_pool_map_put(void) 268 285 { 269 286 struct svc_pool_map *m = &svc_pool_map; ··· 280 297 281 298 mutex_unlock(&svc_pool_map_mutex); 282 299 } 283 - 300 + EXPORT_SYMBOL_GPL(svc_pool_map_put); 284 301 285 302 static int svc_pool_map_get_node(unsigned int pidx) 286 303 {