Changeset 269 for ksyslog/trunk
- Timestamp:
- 05/08/14 00:04:21 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ksyslog/trunk/ksyslog.c
r268 r269 22 22 static struct socket *ksyslog_rcv_sk = NULL; 23 23 24 static struct delayed_work ksyslog_work;24 static struct delayed_work __percpu *ksyslog_work = NULL; 25 25 static struct workqueue_struct *ksyslog_wq = NULL; 26 26 … … 297 297 298 298 static void 299 ksyslog_work_register_cpu(int cpu, struct delayed_work *work, unsigned long timer) 300 { 301 queue_delayed_work_on(cpu, ksyslog_wq, work, timer * HZ / 1000); 302 } 303 304 static void 299 305 ksyslog_work_register(unsigned long timer) 300 306 { 301 queue_delayed_work(ksyslog_wq, &ksyslog_work, timer * HZ / 1000); 307 int cpu; 308 309 for_each_possible_cpu(cpu) 310 ksyslog_work_register_cpu(cpu, per_cpu_ptr(ksyslog_work, cpu), timer); 302 311 } 303 312 … … 305 314 ksyslog_work_unregister(void) 306 315 { 307 cancel_delayed_work_sync(&ksyslog_work); 316 int cpu; 317 318 for_each_possible_cpu(cpu) 319 cancel_delayed_work_sync(per_cpu_ptr(ksyslog_work, cpu)); 308 320 } 309 321 … … 348 360 349 361 out: 350 ksyslog_work_register(ksyslog_flush_interval); 362 ksyslog_work_register_cpu(smp_processor_id(), 363 per_cpu_ptr(ksyslog_work, smp_processor_id()), 364 ksyslog_flush_interval); 351 365 } 352 366 … … 617 631 ksyslog_rcv_sk = NULL; 618 632 619 if (ksyslog_w q) {633 if (ksyslog_work) { 620 634 ksyslog_work_unregister(); 635 free_percpu(ksyslog_work); 636 } 637 ksyslog_work = NULL; 638 639 if (ksyslog_wq) 621 640 destroy_workqueue(ksyslog_wq); 622 }623 641 ksyslog_wq = NULL; 624 642 … … 636 654 ksyslog_init(void) 637 655 { 638 int err;656 int cpu, err; 639 657 struct sockaddr_in sin; 640 658 … … 656 674 } 657 675 658 INIT_DELAYED_WORK(&ksyslog_work, ksyslog_work_handler); 676 ksyslog_work = alloc_percpu(struct delayed_work); 677 if (!ksyslog_work) { 678 pr_err("ksyslog: alloc_percpu(ksyslog_work) failed\n"); 679 err = -ENOMEM; 680 goto err; 681 } 682 for_each_possible_cpu(cpu) 683 INIT_DELAYED_WORK(per_cpu_ptr(ksyslog_work, cpu), ksyslog_work_handler); 659 684 660 685 err = sock_create(AF_INET, SOCK_DGRAM, 0, &ksyslog_rcv_sk);
Note: See TracChangeset
for help on using the changeset viewer.