Skip to content

Commit 52bad64

Browse files
committed
WorkStruct: Separate delayable and non-delayable events.
Separate delayable work items from non-delayable work items be splitting them into a separate structure (delayed_work), which incorporates a work_struct and the timer_list removed from work_struct. The work_struct struct is huge, and this limits it's usefulness. On a 64-bit architecture it's nearly 100 bytes in size. This reduces that by half for the non-delayable type of event. Signed-Off-By: David Howells <dhowells@redhat.com>
1 parent 0f9005a commit 52bad64

22 files changed

Lines changed: 96 additions & 73 deletions

File tree

‎arch/x86_64/kernel/mce.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void mce_log_therm_throt_event(unsigned int cpu, __u64 status)
307307

308308
static int check_interval = 5 * 60; /* 5 minutes */
309309
static void mcheck_timer(void *data);
310-
static DECLARE_WORK(mcheck_work, mcheck_timer, NULL);
310+
static DECLARE_DELAYED_WORK(mcheck_work, mcheck_timer, NULL);
311311

312312
static void mcheck_check_cpu(void *info)
313313
{

‎drivers/ata/libata-core.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,9 @@ void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data,
937937
if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK)
938938
return;
939939

940-
PREPARE_WORK(&ap->port_task, fn, data);
940+
PREPARE_DELAYED_WORK(&ap->port_task, fn, data);
941941

942-
if (!delay)
943-
rc = queue_work(ata_wq, &ap->port_task);
944-
else
945-
rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
942+
rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
946943

947944
/* rc == 0 means that another user is using port task */
948945
WARN_ON(rc == 0);
@@ -5320,8 +5317,8 @@ void ata_port_init(struct ata_port *ap, struct ata_host *host,
53205317
ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
53215318
#endif
53225319

5323-
INIT_WORK(&ap->port_task, NULL, NULL);
5324-
INIT_WORK(&ap->hotplug_task, ata_scsi_hotplug, ap);
5320+
INIT_DELAYED_WORK(&ap->port_task, NULL, NULL);
5321+
INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug, ap);
53255322
INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan, ap);
53265323
INIT_LIST_HEAD(&ap->eh_done_q);
53275324
init_waitqueue_head(&ap->eh_wait_q);

‎drivers/ata/libata-eh.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ void ata_scsi_error(struct Scsi_Host *host)
332332
if (ap->pflags & ATA_PFLAG_LOADING)
333333
ap->pflags &= ~ATA_PFLAG_LOADING;
334334
else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
335-
queue_work(ata_aux_wq, &ap->hotplug_task);
335+
queue_delayed_work(ata_aux_wq, &ap->hotplug_task, 0);
336336

337337
if (ap->pflags & ATA_PFLAG_RECOVERED)
338338
ata_port_printk(ap, KERN_INFO, "EH complete\n");

‎drivers/char/random.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ static unsigned int ip_cnt;
14241424

14251425
static void rekey_seq_generator(void *private_);
14261426

1427-
static DECLARE_WORK(rekey_work, rekey_seq_generator, NULL);
1427+
static DECLARE_DELAYED_WORK(rekey_work, rekey_seq_generator, NULL);
14281428

14291429
/*
14301430
* Lock avoidance:

‎drivers/char/tty_io.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3580,7 +3580,7 @@ static void initialize_tty_struct(struct tty_struct *tty)
35803580
tty->overrun_time = jiffies;
35813581
tty->buf.head = tty->buf.tail = NULL;
35823582
tty_buffer_init(tty);
3583-
INIT_WORK(&tty->buf.work, flush_to_ldisc, tty);
3583+
INIT_DELAYED_WORK(&tty->buf.work, flush_to_ldisc, tty);
35843584
init_MUTEX(&tty->buf.pty_sem);
35853585
mutex_init(&tty->termios_mutex);
35863586
init_waitqueue_head(&tty->write_wait);

‎fs/aio.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
227227

228228
INIT_LIST_HEAD(&ctx->active_reqs);
229229
INIT_LIST_HEAD(&ctx->run_list);
230-
INIT_WORK(&ctx->wq, aio_kick_handler, ctx);
230+
INIT_DELAYED_WORK(&ctx->wq, aio_kick_handler, ctx);
231231

232232
if (aio_setup_ring(ctx) < 0)
233233
goto out_freectx;
@@ -876,7 +876,7 @@ static void aio_kick_handler(void *data)
876876
* we're in a worker thread already, don't use queue_delayed_work,
877877
*/
878878
if (requeue)
879-
queue_work(aio_wq, &ctx->wq);
879+
queue_delayed_work(aio_wq, &ctx->wq, 0);
880880
}
881881

882882

‎fs/nfs/client.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static struct nfs_client *nfs_alloc_client(const char *hostname,
143143
INIT_LIST_HEAD(&clp->cl_state_owners);
144144
INIT_LIST_HEAD(&clp->cl_unused);
145145
spin_lock_init(&clp->cl_lock);
146-
INIT_WORK(&clp->cl_renewd, nfs4_renew_state, clp);
146+
INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state, clp);
147147
rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
148148
clp->cl_boot_time = CURRENT_TIME;
149149
clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;

‎fs/nfs/namespace.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
static void nfs_expire_automounts(void *list);
2222

2323
LIST_HEAD(nfs_automount_list);
24-
static DECLARE_WORK(nfs_automount_task, nfs_expire_automounts, &nfs_automount_list);
24+
static DECLARE_DELAYED_WORK(nfs_automount_task, nfs_expire_automounts,
25+
&nfs_automount_list);
2526
int nfs_mountpoint_expiry_timeout = 500 * HZ;
2627

2728
static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,

‎include/linux/aio.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct kioctx {
194194

195195
struct aio_ring_info ring_info;
196196

197-
struct work_struct wq;
197+
struct delayed_work wq;
198198
};
199199

200200
/* prototypes */

‎include/linux/kbd_kern.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static inline void con_schedule_flip(struct tty_struct *t)
158158
if (t->buf.tail != NULL)
159159
t->buf.tail->commit = t->buf.tail->used;
160160
spin_unlock_irqrestore(&t->buf.lock, flags);
161-
schedule_work(&t->buf.work);
161+
schedule_delayed_work(&t->buf.work, 0);
162162
}
163163

164164
#endif

0 commit comments

Comments
 (0)