drbd: Converted drbd_calc_cpu_mask() and drbd_thread_current_set_cpu() from mdev to tconn
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
parent
907599e044
commit
808222845d
|
@ -946,6 +946,7 @@ struct drbd_tconn { /* is a resource from the config file */
|
||||||
struct drbd_thread receiver;
|
struct drbd_thread receiver;
|
||||||
struct drbd_thread worker;
|
struct drbd_thread worker;
|
||||||
struct drbd_thread asender;
|
struct drbd_thread asender;
|
||||||
|
cpumask_var_t cpu_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct drbd_conf {
|
struct drbd_conf {
|
||||||
|
@ -1075,7 +1076,6 @@ struct drbd_conf {
|
||||||
spinlock_t peer_seq_lock;
|
spinlock_t peer_seq_lock;
|
||||||
unsigned int minor;
|
unsigned int minor;
|
||||||
unsigned long comm_bm_set; /* communicated number of set bits. */
|
unsigned long comm_bm_set; /* communicated number of set bits. */
|
||||||
cpumask_var_t cpu_mask;
|
|
||||||
struct bm_io_work bm_io_work;
|
struct bm_io_work bm_io_work;
|
||||||
u64 ed_uuid; /* UUID of the exposed data */
|
u64 ed_uuid; /* UUID of the exposed data */
|
||||||
struct mutex state_mutex;
|
struct mutex state_mutex;
|
||||||
|
@ -1149,10 +1149,10 @@ extern int drbd_thread_start(struct drbd_thread *thi);
|
||||||
extern void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait);
|
extern void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait);
|
||||||
extern char *drbd_task_to_thread_name(struct drbd_conf *mdev, struct task_struct *task);
|
extern char *drbd_task_to_thread_name(struct drbd_conf *mdev, struct task_struct *task);
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
extern void drbd_thread_current_set_cpu(struct drbd_conf *mdev, struct drbd_thread *thi);
|
extern void drbd_thread_current_set_cpu(struct drbd_thread *thi);
|
||||||
extern void drbd_calc_cpu_mask(struct drbd_conf *mdev);
|
extern void drbd_calc_cpu_mask(struct drbd_tconn *tconn);
|
||||||
#else
|
#else
|
||||||
#define drbd_thread_current_set_cpu(A, B) ({})
|
#define drbd_thread_current_set_cpu(A) ({})
|
||||||
#define drbd_calc_cpu_mask(A) ({})
|
#define drbd_calc_cpu_mask(A) ({})
|
||||||
#endif
|
#endif
|
||||||
extern void drbd_free_resources(struct drbd_conf *mdev);
|
extern void drbd_free_resources(struct drbd_conf *mdev);
|
||||||
|
|
|
@ -606,6 +606,12 @@ char *drbd_task_to_thread_name(struct drbd_conf *mdev, struct task_struct *task)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
static int conn_lowest_minor(struct drbd_tconn *tconn)
|
||||||
|
{
|
||||||
|
int minor = 0;
|
||||||
|
idr_get_next(&tconn->volumes, &minor);
|
||||||
|
return minor;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* drbd_calc_cpu_mask() - Generate CPU masks, spread over all CPUs
|
* drbd_calc_cpu_mask() - Generate CPU masks, spread over all CPUs
|
||||||
* @mdev: DRBD device.
|
* @mdev: DRBD device.
|
||||||
|
@ -613,23 +619,23 @@ char *drbd_task_to_thread_name(struct drbd_conf *mdev, struct task_struct *task)
|
||||||
* Forces all threads of a device onto the same CPU. This is beneficial for
|
* Forces all threads of a device onto the same CPU. This is beneficial for
|
||||||
* DRBD's performance. May be overwritten by user's configuration.
|
* DRBD's performance. May be overwritten by user's configuration.
|
||||||
*/
|
*/
|
||||||
void drbd_calc_cpu_mask(struct drbd_conf *mdev)
|
void drbd_calc_cpu_mask(struct drbd_tconn *tconn)
|
||||||
{
|
{
|
||||||
int ord, cpu;
|
int ord, cpu;
|
||||||
|
|
||||||
/* user override. */
|
/* user override. */
|
||||||
if (cpumask_weight(mdev->cpu_mask))
|
if (cpumask_weight(tconn->cpu_mask))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ord = mdev_to_minor(mdev) % cpumask_weight(cpu_online_mask);
|
ord = conn_lowest_minor(tconn) % cpumask_weight(cpu_online_mask);
|
||||||
for_each_online_cpu(cpu) {
|
for_each_online_cpu(cpu) {
|
||||||
if (ord-- == 0) {
|
if (ord-- == 0) {
|
||||||
cpumask_set_cpu(cpu, mdev->cpu_mask);
|
cpumask_set_cpu(cpu, tconn->cpu_mask);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* should not be reached */
|
/* should not be reached */
|
||||||
cpumask_setall(mdev->cpu_mask);
|
cpumask_setall(tconn->cpu_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -640,14 +646,14 @@ void drbd_calc_cpu_mask(struct drbd_conf *mdev)
|
||||||
* call in the "main loop" of _all_ threads, no need for any mutex, current won't die
|
* call in the "main loop" of _all_ threads, no need for any mutex, current won't die
|
||||||
* prematurely.
|
* prematurely.
|
||||||
*/
|
*/
|
||||||
void drbd_thread_current_set_cpu(struct drbd_conf *mdev, struct drbd_thread *thi)
|
void drbd_thread_current_set_cpu(struct drbd_thread *thi)
|
||||||
{
|
{
|
||||||
struct task_struct *p = current;
|
struct task_struct *p = current;
|
||||||
|
|
||||||
if (!thi->reset_cpu_mask)
|
if (!thi->reset_cpu_mask)
|
||||||
return;
|
return;
|
||||||
thi->reset_cpu_mask = 0;
|
thi->reset_cpu_mask = 0;
|
||||||
set_cpus_allowed_ptr(p, mdev->cpu_mask);
|
set_cpus_allowed_ptr(p, thi->mdev->tconn->cpu_mask);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2236,7 +2242,7 @@ struct drbd_conf *drbd_new_device(unsigned int minor)
|
||||||
dev_err(DEV, "vnr = %d\n", vnr);
|
dev_err(DEV, "vnr = %d\n", vnr);
|
||||||
goto out_no_cpumask;
|
goto out_no_cpumask;
|
||||||
}
|
}
|
||||||
if (!zalloc_cpumask_var(&mdev->cpu_mask, GFP_KERNEL))
|
if (!zalloc_cpumask_var(&mdev->tconn->cpu_mask, GFP_KERNEL))
|
||||||
goto out_no_cpumask;
|
goto out_no_cpumask;
|
||||||
|
|
||||||
mdev->tconn->volume0 = mdev;
|
mdev->tconn->volume0 = mdev;
|
||||||
|
@ -2313,7 +2319,7 @@ out_no_io_page:
|
||||||
out_no_disk:
|
out_no_disk:
|
||||||
blk_cleanup_queue(q);
|
blk_cleanup_queue(q);
|
||||||
out_no_q:
|
out_no_q:
|
||||||
free_cpumask_var(mdev->cpu_mask);
|
free_cpumask_var(mdev->tconn->cpu_mask);
|
||||||
out_no_cpumask:
|
out_no_cpumask:
|
||||||
drbd_free_tconn(mdev->tconn);
|
drbd_free_tconn(mdev->tconn);
|
||||||
out_no_tconn:
|
out_no_tconn:
|
||||||
|
@ -2332,7 +2338,6 @@ void drbd_free_mdev(struct drbd_conf *mdev)
|
||||||
__free_page(mdev->md_io_page);
|
__free_page(mdev->md_io_page);
|
||||||
put_disk(mdev->vdisk);
|
put_disk(mdev->vdisk);
|
||||||
blk_cleanup_queue(mdev->rq_queue);
|
blk_cleanup_queue(mdev->rq_queue);
|
||||||
free_cpumask_var(mdev->cpu_mask);
|
|
||||||
kfree(mdev);
|
kfree(mdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1884,9 +1884,9 @@ static int drbd_nl_syncer_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n
|
||||||
if (mdev->state.conn >= C_CONNECTED)
|
if (mdev->state.conn >= C_CONNECTED)
|
||||||
drbd_send_sync_param(mdev, &sc);
|
drbd_send_sync_param(mdev, &sc);
|
||||||
|
|
||||||
if (!cpumask_equal(mdev->cpu_mask, new_cpu_mask)) {
|
if (!cpumask_equal(mdev->tconn->cpu_mask, new_cpu_mask)) {
|
||||||
cpumask_copy(mdev->cpu_mask, new_cpu_mask);
|
cpumask_copy(mdev->tconn->cpu_mask, new_cpu_mask);
|
||||||
drbd_calc_cpu_mask(mdev);
|
drbd_calc_cpu_mask(mdev->tconn);
|
||||||
mdev->tconn->receiver.reset_cpu_mask = 1;
|
mdev->tconn->receiver.reset_cpu_mask = 1;
|
||||||
mdev->tconn->asender.reset_cpu_mask = 1;
|
mdev->tconn->asender.reset_cpu_mask = 1;
|
||||||
mdev->tconn->worker.reset_cpu_mask = 1;
|
mdev->tconn->worker.reset_cpu_mask = 1;
|
||||||
|
|
|
@ -3779,7 +3779,7 @@ static void drbdd(struct drbd_conf *mdev)
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
while (get_t_state(&mdev->tconn->receiver) == RUNNING) {
|
while (get_t_state(&mdev->tconn->receiver) == RUNNING) {
|
||||||
drbd_thread_current_set_cpu(mdev, &mdev->tconn->receiver);
|
drbd_thread_current_set_cpu(&mdev->tconn->receiver);
|
||||||
if (!drbd_recv_header(mdev->tconn, &pi))
|
if (!drbd_recv_header(mdev->tconn, &pi))
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
|
@ -4568,7 +4568,7 @@ int drbd_asender(struct drbd_thread *thi)
|
||||||
current->rt_priority = 2; /* more important than all other tasks */
|
current->rt_priority = 2; /* more important than all other tasks */
|
||||||
|
|
||||||
while (get_t_state(thi) == RUNNING) {
|
while (get_t_state(thi) == RUNNING) {
|
||||||
drbd_thread_current_set_cpu(mdev, thi);
|
drbd_thread_current_set_cpu(thi);
|
||||||
if (test_and_clear_bit(SEND_PING, &mdev->tconn->flags)) {
|
if (test_and_clear_bit(SEND_PING, &mdev->tconn->flags)) {
|
||||||
if (!drbd_send_ping(mdev)) {
|
if (!drbd_send_ping(mdev)) {
|
||||||
dev_err(DEV, "drbd_send_ping has failed\n");
|
dev_err(DEV, "drbd_send_ping has failed\n");
|
||||||
|
|
|
@ -1634,7 +1634,7 @@ int drbd_worker(struct drbd_thread *thi)
|
||||||
sprintf(current->comm, "drbd%d_worker", mdev_to_minor(mdev));
|
sprintf(current->comm, "drbd%d_worker", mdev_to_minor(mdev));
|
||||||
|
|
||||||
while (get_t_state(thi) == RUNNING) {
|
while (get_t_state(thi) == RUNNING) {
|
||||||
drbd_thread_current_set_cpu(mdev, thi);
|
drbd_thread_current_set_cpu(thi);
|
||||||
|
|
||||||
if (down_trylock(&mdev->tconn->data.work.s)) {
|
if (down_trylock(&mdev->tconn->data.work.s)) {
|
||||||
mutex_lock(&mdev->tconn->data.mutex);
|
mutex_lock(&mdev->tconn->data.mutex);
|
||||||
|
|
Loading…
Reference in New Issue