Skip to contentSkip to conversation

perf/core: Replace 1 with true

PATCH Yejune Deng 1 participant 1 message Dec 11, 2020 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Can my submission be accepted ? Do I need to do something, or wait for news?

Quoted 48 lines · Mark Rutland
Quoted 15 lines · Peter Zijlstra
Quoted 14 lines · Yejune Deng

In task_css_check(), the third parameter 'true' looks more readable.

---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +0 -0
index d2f3ca7..0700022 100644
@@ -7265,7 +7265,7 @@ void perf_prepare_sample(struct perf_event_header *header,
            struct cgroup *cgrp;
 
Quoted 5 lines

kernel/events/core.c void perf_prepare_sample(struct perf_event_header *header, · line 7268

Quoted 3 lines
kernel/events/core.c +1 -1
            /* protected by RCU */
-           cgrp = task_css_check(current, perf_event_cgrp_id, 1)->cgroup;
+           cgrp = task_css_check(current, perf_event_cgrp_id, true)->cgroup;

it looks like 3 wasted bytes to me

I disagree; I think it'd make sense to do this for consistency, given all the other callers pass true/false (including in the header where this is defined):

| [mark@lakrids:~/src/linux]% git grep task_css_check
| include/linux/cgroup.h: * task_css_check - obtain css for (task, subsys) w/ extra access conds
| include/linux/cgroup.h:#define task_css_check(task, subsys_id, __c)                             \
| include/linux/cgroup.h: * See task_css_check().
| include/linux/cgroup.h: return task_css_check(task, subsys_id, false);
| include/linux/cgroup.h: return task_css_check(task, subsys_id, true) ==
| include/linux/perf_event.h:     return container_of(task_css_check(task, perf_event_cgrp_id,
| kernel/cgroup/pids.c: * task_css_check(true) in pids_can_fork() and pids_cancel_fork() relies
| kernel/cgroup/pids.c:           css = task_css_check(current, pids_cgrp_id, true);
| kernel/cgroup/pids.c:           css = task_css_check(current, pids_cgrp_id, true);
| kernel/events/core.c:           cgrp = task_css_check(current, perf_event_cgrp_id, 1)->cgroup;
| kernel/sched/core.c:     * which is pointless here. Thus, we pass "true" to task_css_check()
| kernel/sched/core.c:    tg = container_of(task_css_check(tsk, cpu_cgrp_id, true),
| net/core/netclassid_cgroup.c:   return css_cls_state(task_css_check(p, net_cls_cgrp_id,

... but it'd be helpful if this could be cc'd to LKML ([email protected]), rather than just the maintainers off-list.

... or we could waste more than 3 bytes arguing. ;)

Thanks,
Mark.