Skip to content

Commit

Permalink
staging/lustre: fix build error when !CONFIG_SMP
Browse files Browse the repository at this point in the history
Three functions cfs_cpu_ht_nsiblings, cfs_cpt_cpumask and
cfs_cpt_table_print are missing if !CONFIG_SMP.

cpumask_t/nodemask_t/__read_mostly/____cacheline_aligned
are redefined.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Peng Tao authored and Greg Kroah-Hartman committed Jul 23, 2013
1 parent 5e8f692 commit 3867ea5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 74 deletions.
46 changes: 23 additions & 23 deletions drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@
#ifndef __LIBCFS_CPU_H__
#define __LIBCFS_CPU_H__

#ifndef HAVE_LIBCFS_CPT

typedef unsigned long cpumask_t;
typedef unsigned long nodemask_t;
/* any CPU partition */
#define CFS_CPT_ANY (-1)

#ifdef CONFIG_SMP
/**
* return cpumask of CPU partition \a cpt
*/
cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt);
/**
* print string information of cpt-table
*/
int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len);
#else /* !CONFIG_SMP */
struct cfs_cpt_table {
/* # of CPU partitions */
int ctb_nparts;
Expand All @@ -91,10 +99,18 @@ struct cfs_cpt_table {
__u64 ctb_version;
};

#endif /* !HAVE_LIBCFS_CPT */
static inline cpumask_t *
cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
{
return NULL;
}

/* any CPU partition */
#define CFS_CPT_ANY (-1)
static inline int
cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
return 0;
}
#endif /* CONFIG_SMP */

extern struct cfs_cpt_table *cfs_cpt_table;

Expand All @@ -106,10 +122,6 @@ void cfs_cpt_table_free(struct cfs_cpt_table *cptab);
* create a cfs_cpt_table with \a ncpt number of partitions
*/
struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
/**
* print string information of cpt-table
*/
int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len);
/**
* return total number of CPU partitions in \a cptab
*/
Expand All @@ -123,10 +135,6 @@ int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt);
* is there any online CPU in CPU partition \a cpt
*/
int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt);
/**
* return cpumask of CPU partition \a cpt
*/
cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt);
/**
* return nodemask of CPU partition \a cpt
*/
Expand Down Expand Up @@ -200,14 +208,6 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt);
#define cfs_cpt_for_each(i, cptab) \
for (i = 0; i < cfs_cpt_number(cptab); i++)

#ifndef __read_mostly
# define __read_mostly
#endif

#ifndef ____cacheline_aligned
#define ____cacheline_aligned
#endif

int cfs_cpu_init(void);
void cfs_cpu_fini(void);

Expand Down
6 changes: 0 additions & 6 deletions drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ struct cfs_cpt_table {
nodemask_t *ctb_nodemask;
};

void cfs_cpu_core_siblings(int cpu, cpumask_t *mask);
void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask);
void cfs_node_to_cpumask(int node, cpumask_t *mask);
int cfs_cpu_core_nsiblings(int cpu);
int cfs_cpu_ht_nsiblings(int cpu);

/**
* comment out definitions for compatible layer
* #define CFS_CPU_NR NR_CPUS
Expand Down
2 changes: 2 additions & 0 deletions drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,8 @@ kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
return 0;

mask = cfs_cpt_cpumask(lnet_cpt_table(), cpt);
if (mask == NULL)
return 0;

/* hash NID to CPU id in this partition... */
off = do_div(nid, cpus_weight(*mask));
Expand Down
46 changes: 3 additions & 43 deletions drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,62 +76,22 @@ struct cfs_cpt_data {

static struct cfs_cpt_data cpt_data;

void
cfs_cpu_core_siblings(int cpu, cpumask_t *mask)
static void cfs_cpu_core_siblings(int cpu, cpumask_t *mask)
{
/* return cpumask of cores in the same socket */
cpumask_copy(mask, topology_core_cpumask(cpu));
}
EXPORT_SYMBOL(cfs_cpu_core_siblings);

/* return number of cores in the same socket of \a cpu */
int
cfs_cpu_core_nsiblings(int cpu)
{
int num;

down(&cpt_data.cpt_mutex);

cfs_cpu_core_siblings(cpu, cpt_data.cpt_cpumask);
num = cpus_weight(*cpt_data.cpt_cpumask);

up(&cpt_data.cpt_mutex);

return num;
}
EXPORT_SYMBOL(cfs_cpu_core_nsiblings);

/* return cpumask of HTs in the same core */
void
cfs_cpu_ht_siblings(int cpu, cpumask_t *mask)
static void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask)
{
cpumask_copy(mask, topology_thread_cpumask(cpu));
}
EXPORT_SYMBOL(cfs_cpu_ht_siblings);

/* return number of HTs in the same core of \a cpu */
int
cfs_cpu_ht_nsiblings(int cpu)
{
int num;

down(&cpt_data.cpt_mutex);

cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask);
num = cpus_weight(*cpt_data.cpt_cpumask);

up(&cpt_data.cpt_mutex);

return num;
}
EXPORT_SYMBOL(cfs_cpu_ht_nsiblings);

void
cfs_node_to_cpumask(int node, cpumask_t *mask)
static void cfs_node_to_cpumask(int node, cpumask_t *mask)
{
cpumask_copy(mask, cpumask_of_node(node));
}
EXPORT_SYMBOL(cfs_node_to_cpumask);

void
cfs_cpt_table_free(struct cfs_cpt_table *cptab)
Expand Down
11 changes: 9 additions & 2 deletions drivers/staging/lustre/lustre/ptlrpc/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
if (tc->tc_thr_factor != 0) {
int factor = tc->tc_thr_factor;
const int fade = 4;
cpumask_t mask;

/*
* User wants to increase number of threads with for
Expand All @@ -564,7 +565,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
* have too many threads no matter how many cores/HTs
* there are.
*/
if (cfs_cpu_ht_nsiblings(0) > 1) { /* weight is # of HTs */
cpumask_copy(&mask, topology_thread_cpumask(0));
if (cpus_weight(mask) > 1) { /* weight is # of HTs */
/* depress thread factor for hyper-thread */
factor = factor - (factor >> 1) + (factor >> 3);
}
Expand Down Expand Up @@ -2776,11 +2778,13 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)

int ptlrpc_hr_init(void)
{
cpumask_t mask;
struct ptlrpc_hr_partition *hrp;
struct ptlrpc_hr_thread *hrt;
int rc;
int i;
int j;
int weight;
ENTRY;

memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr));
Expand All @@ -2793,14 +2797,17 @@ int ptlrpc_hr_init(void)

init_waitqueue_head(&ptlrpc_hr.hr_waitq);

cpumask_copy(&mask, topology_thread_cpumask(0));
weight = cpus_weight(mask);

cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
hrp->hrp_cpt = i;

atomic_set(&hrp->hrp_nstarted, 0);
atomic_set(&hrp->hrp_nstopped, 0);

hrp->hrp_nthrs = cfs_cpt_weight(ptlrpc_hr.hr_cpt_table, i);
hrp->hrp_nthrs /= cfs_cpu_ht_nsiblings(0);
hrp->hrp_nthrs /= weight;

LASSERT(hrp->hrp_nthrs > 0);
OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i,
Expand Down

0 comments on commit 3867ea5

Please sign in to comment.