The patch titled per task delay accounting taskstats interface: code cleanup has been added to the -mm tree. Its filename is per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix-cleanup.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: per task delay accounting taskstats interface: code cleanup From: Shailabh Nagar <nagar@xxxxxxxxxxxxxx> Cleanup cpumask related code and rearrange functions for clarity Signed-off-by: Shailabh Nagar <nagar@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- include/linux/taskstats_kern.h | 5 -- kernel/taskstats.c | 53 ++++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff -puN include/linux/taskstats_kern.h~per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix-cleanup include/linux/taskstats_kern.h --- a/include/linux/taskstats_kern.h~per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix-cleanup +++ a/include/linux/taskstats_kern.h @@ -11,11 +11,6 @@ #include <linux/sched.h> #include <net/genetlink.h> -enum { - TASKSTATS_MSG_UNICAST, /* send data only to requester */ - TASKSTATS_MSG_MULTICAST, /* send data to a group */ -}; - #ifdef CONFIG_TASKSTATS extern kmem_cache_t *taskstats_cache; extern struct mutex taskstats_exit_mutex; diff -puN kernel/taskstats.c~per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix-cleanup kernel/taskstats.c --- a/kernel/taskstats.c~per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix-cleanup +++ a/kernel/taskstats.c @@ -99,35 +99,45 @@ static int prepare_reply(struct genl_inf return 0; } -static int send_reply(struct sk_buff *skb, pid_t pid, int event, unsigned int cpu) +/* + * Send taskstats data in @skb to listener with nl_pid @pid + */ +static int send_reply(struct sk_buff *skb, pid_t pid) { struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data); - struct listener_list *listeners; - struct list_head *p, *tmp; - void *reply; + void *reply = genlmsg_data(genlhdr); int rc; - reply = genlmsg_data(genlhdr); - rc = genlmsg_end(skb, reply); if (rc < 0) { nlmsg_free(skb); return rc; } - if (event == TASKSTATS_MSG_UNICAST) - return genlmsg_unicast(skb, pid); + return genlmsg_unicast(skb, pid); +} - /* - * Taskstats multicast is unicasts to listeners who have registered - * interest in cpu - */ +/* + * Send taskstats data in @skb to listeners registered for @cpu's exit data + */ +static int send_cpu_listeners(struct sk_buff *skb, unsigned int cpu) +{ + struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data); + struct listener_list *listeners; + struct listener *s, *tmp; + void *reply = genlmsg_data(genlhdr); + int rc, ret; + + rc = genlmsg_end(skb, reply); + if (rc < 0) { + nlmsg_free(skb); + return rc; + } + rc = 0; listeners = &per_cpu(listener_array, cpu); down_write(&listeners->sem); - list_for_each_safe(p, tmp, &listeners->list) { - int ret; - struct listener *s = list_entry(p, struct listener, list); + list_for_each_entry_safe(s, tmp, &listeners->list, list) { ret = genlmsg_unicast(skb, s->pid); if (ret) { list_del(&s->list); @@ -253,11 +263,10 @@ ret: static int add_del_listener(pid_t pid, cpumask_t *maskp, int isadd) { - struct listener *s; struct listener_list *listeners; + struct listener *s, *tmp; unsigned int cpu; cpumask_t mask = *maskp; - struct list_head *p; if (!cpus_subset(mask, cpu_possible_map)) return -EINVAL; @@ -282,12 +291,9 @@ static int add_del_listener(pid_t pid, c /* Deregister or cleanup */ cleanup: for_each_cpu_mask(cpu, mask) { - struct list_head *tmp; - listeners = &per_cpu(listener_array, cpu); down_write(&listeners->sem); - list_for_each_safe(p, tmp, &listeners->list) { - s = list_entry(p, struct listener, list); + list_for_each_entry_safe(s, tmp, &listeners->list, list) { if (s->pid == pid) { list_del(&s->list); kfree(s); @@ -381,8 +387,7 @@ static int taskstats_user_cmd(struct sk_ nla_nest_end(rep_skb, na); - return send_reply(rep_skb, info->snd_pid, TASKSTATS_MSG_UNICAST, - CPU_DONT_CARE); + return send_reply(rep_skb, info->snd_pid); nla_put_failure: return genlmsg_cancel(rep_skb, reply); @@ -480,7 +485,7 @@ void taskstats_exit_send(struct task_str nla_nest_end(rep_skb, na); send: - send_reply(rep_skb, 0, TASKSTATS_MSG_MULTICAST, mycpu); + send_cpu_listeners(rep_skb, mycpu); return; nla_put_failure: _ Patches currently in -mm which might be from nagar@xxxxxxxxxxxxxx are netlink-improve-string-attribute-validation.patch list_islast-utility.patch per-task-delay-accounting-setup.patch per-task-delay-accounting-sync-block-i-o-and-swapin-delay-collection.patch per-task-delay-accounting-cpu-delay-collection-via-schedstats.patch per-task-delay-accounting-utilities-for-genetlink-usage.patch per-task-delay-accounting-taskstats-interface.patch per-task-delay-accounting-delay-accounting-usage-of-taskstats-interface.patch per-task-delay-accounting-documentation.patch per-task-delay-accounting-proc-export-of-aggregated-block-i-o-delays.patch delay-accounting-taskstats-interface-send-tgid-once.patch per-task-delay-accounting-avoid-send-without-listeners.patch per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks.patch per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix.patch per-task-delay-accounting-taskstats-interface-control-exit-data-through-cpumasks-fix-cleanup.patch per-task-delay-accounting-taskstats-interface-documentation-fix.patch per-task-delay-accounting-taskstats-interface-fix-early-sem-init.patch per-task-delay-accounting-taskstats-interface-fix-drop-listener-only-on-socket-close.patch per-task-delay-accounting-taskstats-interface-fix-clone-skbs-for-each-listener.patch task-watchers-register-per-task-delay-accounting.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html