public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Wagner <daniel.wagner@bmw-carit.de>
To: Alexei Starovoitov <ast@plumgrid.com>, <paulmck@linux.vnet.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: call_rcu from trace_preempt
Date: Tue, 16 Jun 2015 08:34:07 +0200	[thread overview]
Message-ID: <557FC35F.1020506@bmw-carit.de> (raw)
In-Reply-To: <557FC14C.9080901@plumgrid.com>

On 06/16/2015 08:25 AM, Alexei Starovoitov wrote:
> On 6/15/15 11:06 PM, Daniel Wagner wrote:
>>> with the above 'fix' the trace.patch is now passing.
>> It still crashes for me with the original test program
>>
>> [  145.908013]  [<ffffffff810d1da1>] ? __rcu_reclaim+0x101/0x3d0
>> [  145.908013]  [<ffffffff810d1ca0>] ? rcu_barrier_func+0x250/0x250
>> [  145.908013]  [<ffffffff810abc03>] ?
>> trace_hardirqs_on_caller+0xf3/0x240
>> [  145.908013]  [<ffffffff810d9afa>] rcu_do_batch+0x2ea/0x6b0
> 
> yes. full bpf test still crashes.
> That's why I said trace.patch is passing ;)
> There is something else in there. One 'fix' at a time.

Ah, sorry, I read it is working now :) Anyway, I'll keep looking
as well.

Yesterday I wrote a small torture program for the map
implementation. Just to rule out memory corruption there.
Are you interested in it? If yes I could clean it a bit.

It is based on Paul's rcu torturing (Finally I can write 
this word without a typo :))

Here a rough/dirty version:

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/bpf.h>
#include <linux/torture.h>
#include <linux/slab.h>

struct bpf_test {
	struct bpf_map *map;
	const struct bpf_map_ops *ops;
};

static struct bpf_test test;
static struct task_struct **torture_reads;
static struct task_struct **torture_writes;

torture_param(int, nreads, -1, "Number of BPF torture threads");
torture_param(int, nwrites, -1, "Number of BPF torture threads");
torture_param(int, onoff_holdoff, 0, "Time after boot before CPU hotplugs (s)");
torture_param(int, onoff_interval, 0, "Time between CPU hotplugs (s), 0=disable");
torture_param(int, shutdown_secs, 0, "Shutdown time (s), <= zero to disable.");
torture_param(int, stutter, 5, "Number of seconds to run/halt test");
torture_param(bool, verbose, true,
	     "Enable verbose debugging printk()s");

static int nrealreads;
static int nrealwrites;

static int torture_runnable = 1;
module_param(torture_runnable, int, 0444);
MODULE_PARM_DESC(torture_runnable, "Start rcutorture at boot");

static char *torture_type = "bpf";
module_param(torture_type, charp, 0444);
MODULE_PARM_DESC(torture_type, "Type of BPF to torture ( ...)");

static int bpf_torture_writes(void *arg)
{
	int i, v;
	do {
		v = 1234;
		rcu_read_lock();
		for (i = 0; i < 1000; i++) {
			test.ops->map_update_elem(test.map, &v, &v, BPF_ANY);
			v = next_pseudo_random32(v);
		}
		rcu_read_unlock();

		stutter_wait("bpf_torture_write");
	} while (!torture_must_stop());

	torture_kthread_stopping("bpf_torture_write");
	return 0;
}

static int bpf_torture_reads(void *arg)
{
	int *r;
	int key, next_key;

	do {
		key = -1;
		rcu_read_lock();
		while (test.ops->map_get_next_key(test.map, &key, &next_key) == 0) {
			r = test.ops->map_lookup_elem(test.map, &next_key);
			test.ops->map_delete_elem(test.map, &next_key);
			key = next_key;
		}
		rcu_read_unlock();

		stutter_wait("bpf_torture_read");
	} while (!torture_must_stop());

	torture_kthread_stopping("bpf_torture_read");
	return 0;
}

static void bpf_torture_cleanup(void)
{
	int i;

	torture_cleanup_begin();

	if (torture_reads) {
		for (i = 0; i < nrealreads; i++)
			torture_stop_kthread(rcu_torture_reads,
					torture_reads[i]);
		kfree(torture_reads);
	}

	if (torture_writes) {
		for (i = 0; i < nrealwrites; i++)
			torture_stop_kthread(rcu_torture_writes,
					torture_writes[i]);
		kfree(torture_writes);
	}

	if (!test.map) {
		test.ops->map_free(test.map);
		test.map = NULL;
	}

	torture_cleanup_end();
}

static int __init bpf_torture_init(void)
{
	union bpf_attr attr;
	int i, err;

	if (nreads >= 0) {
		nrealreads = nreads;
	} else {
		nrealreads = num_online_cpus() - 1;
		if (nrealreads <= 0)
			nrealreads = 1;
	}

	if (nwrites >= 0) {
		nrealwrites = nwrites;
	} else {
		nrealwrites = num_online_cpus() - 1;
		if (nrealwrites <= 0)
			nrealwrites = 1;
	}

	if (!torture_init_begin(torture_type, verbose, &torture_runnable))
		return -EBUSY;

	torture_reads = kzalloc(nrealreads * sizeof(torture_reads[0]), GFP_KERNEL);
	if (!torture_reads)
		return -ENOMEM;
	torture_writes = kzalloc(nrealwrites * sizeof(torture_writes[0]), GFP_KERNEL);
	if (!torture_writes)
		return -ENOMEM;

	attr.map_type = BPF_MAP_TYPE_HASH;
	attr.key_size = sizeof(u32);
	attr.value_size = sizeof(u32);
	attr.max_entries = 1000;

	test.ops = bpf_get_map_ops(attr.map_type);
	if (!test.ops)
		return -ENOENT;

	test.map = test.ops->map_alloc(&attr);
	if (IS_ERR(test.map))
		return PTR_ERR(test.map);

	err = torture_stutter_init(stutter * HZ);
	if (err)
		return err;

	for (i = 0; i < nrealreads; i++) {
		err = torture_create_kthread(bpf_torture_reads,
					NULL, torture_reads[i]);
		if (err)
			return err;
	}

	for (i = 0; i < nrealwrites; i++) {
		err = torture_create_kthread(bpf_torture_writes,
					NULL, torture_writes[i]);
		if (err)
			return err;
	}

	err = torture_shutdown_init(shutdown_secs, bpf_torture_cleanup);
	if (err)
		return err;

	err = torture_onoff_init(onoff_holdoff * HZ, onoff_interval * HZ);
	if (err)
		return err;

	torture_init_end();

	return 0;
}

module_init(bpf_torture_init);
module_exit(bpf_torture_cleanup);

MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Daniel Wagner <daniel.wagner@bmw-carit.de>");
MODULE_DESCRIPTION("BPF torture tests");

  reply	other threads:[~2015-06-16  6:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-15 22:24 call_rcu from trace_preempt Alexei Starovoitov
2015-06-15 23:07 ` Paul E. McKenney
2015-06-16  1:09   ` Alexei Starovoitov
2015-06-16  2:14     ` Paul E. McKenney
2015-06-16  5:45       ` Alexei Starovoitov
2015-06-16  6:06         ` Daniel Wagner
2015-06-16  6:25           ` Alexei Starovoitov
2015-06-16  6:34             ` Daniel Wagner [this message]
2015-06-16  6:46               ` Alexei Starovoitov
2015-06-16  6:54                 ` Daniel Wagner
2015-06-16 12:27         ` Paul E. McKenney
2015-06-16 12:38           ` Daniel Wagner
2015-06-16 14:16             ` Paul E. McKenney
2015-06-16 15:43               ` Steven Rostedt
2015-06-16 16:07                 ` Paul E. McKenney
2015-06-16 17:13                   ` Daniel Wagner
2015-06-16 15:41             ` Steven Rostedt
2015-06-16 15:52               ` Steven Rostedt
2015-06-16 17:11               ` Daniel Wagner
2015-06-16 17:20             ` Alexei Starovoitov
2015-06-16 17:37               ` Steven Rostedt
2015-06-17  0:33                 ` Alexei Starovoitov
2015-06-17  0:47                   ` Steven Rostedt
2015-06-17  1:04                     ` Alexei Starovoitov
2015-06-17  1:19                       ` Steven Rostedt
2015-06-17  8:11               ` Daniel Wagner
2015-06-17  9:05                 ` Daniel Wagner
2015-06-17 18:39                   ` Alexei Starovoitov
2015-06-17 20:37                     ` Paul E. McKenney
2015-06-17 20:53                       ` Alexei Starovoitov
2015-06-17 21:36                         ` Paul E. McKenney
2015-06-17 23:58                           ` Alexei Starovoitov
2015-06-18  0:20                             ` Paul E. McKenney
2015-06-16 15:37           ` Steven Rostedt
2015-06-16 16:05             ` Paul E. McKenney
2015-06-16 17:14               ` Alexei Starovoitov
2015-06-16 17:39                 ` Paul E. McKenney
2015-06-16 18:57                   ` Steven Rostedt
2015-06-16 19:20                     ` Paul E. McKenney
2015-06-16 19:29                       ` Steven Rostedt
2015-06-16 19:34                         ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=557FC35F.1020506@bmw-carit.de \
    --to=daniel.wagner@bmw-carit.de \
    --cc=ast@plumgrid.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox