Re: [tip: core/rcu] rcu/tree: Mark the idle relevant functions noinstr

From: Kim Phillips
Date: Mon Sep 28 2020 - 19:55:25 EST


Hi,

On 5/19/20 2:52 PM, tip-bot2 for Thomas Gleixner wrote:
> The following commit has been merged into the core/rcu branch of tip:
>
> Commit-ID: ff5c4f5cad33061b07c3fb9187506783c0f3cb66
> Gitweb: https://git.kernel.org/tip/ff5c4f5cad33061b07c3fb9187506783c0f3cb66
> Author: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> AuthorDate: Fri, 13 Mar 2020 17:32:17 +01:00
> Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> CommitterDate: Tue, 19 May 2020 15:51:20 +02:00
>
> rcu/tree: Mark the idle relevant functions noinstr
>
> These functions are invoked from context tracking and other places in the
> low level entry code. Move them into the .noinstr.text section to exclude
> them from instrumentation.
>
> Mark the places which are safe to invoke traceable functions with
> instrumentation_begin/end() so objtool won't complain.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Reviewed-by: Alexandre Chartre <alexandre.chartre@xxxxxxxxxx>
> Acked-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Acked-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> Link: https://lkml.kernel.org/r/20200505134100.575356107@xxxxxxxxxxxxx
>
>
> ---

I bisected a system hang condition down to this commit.

To reproduce the hang, compile the below code and execute it as root
on an x86_64 server (AMD or Intel). The code is opening a
PERF_TYPE_TRACEPOINT event with a non-zero pe.config.

If I revert the commit from Linus' ToT, the system stays up.

.config attached.

Thanks,

Kim

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <linux/perf_event.h>
#include <asm/unistd.h>

static long
perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
int cpu, int group_fd, unsigned long flags)
{
int ret;

ret = syscall(__NR_perf_event_open, hw_event, pid, cpu,
group_fd, flags);
return ret;
}

int
main(int argc, char **argv)
{
struct perf_event_attr pe;
long long count;
int fd;

memset(&pe, 0, sizeof(struct perf_event_attr));
pe.type = PERF_TYPE_TRACEPOINT;
pe.size = sizeof(struct perf_event_attr);
pe.config = PERF_COUNT_HW_INSTRUCTIONS;
pe.disabled = 1;
pe.exclude_kernel = 1;
pe.exclude_hv = 1;

fd = perf_event_open(&pe, 0, -1, -1, 0);
if (fd == -1) {
fprintf(stderr, "Error opening leader %llx\n", pe.config);
exit(EXIT_FAILURE);
}
}

Attachment: config.xz
Description: application/xz