public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: David Smith <dsmith@redhat.com>
To: yzhu1 <Yanjun.Zhu@windriver.com>, systemtap@sourceware.org
Subject: Re: [PATCH 1/1] stp: rt: replace spin_lock with stp style lock and use STP_ALLOC_FLAGS
Date: Wed, 28 Oct 2015 17:09:00 -0000	[thread overview]
Message-ID: <5631014A.20202@redhat.com> (raw)
In-Reply-To: <56303328.5030603@windriver.com>

[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]

On 10/27/2015 09:30 PM, yzhu1 wrote:
> On 10/27/2015 05:28 AM, David Smith wrote:
>> On 10/25/2015 10:19 PM, yzhu1 wrote:
>>> Hi, David
>>>
>>> I do not have this backtrace. Because STP_ALLOC_SLEEP_FLAGS will cause
>>> kmalloc sleep,
>>> so I replaced it with STP_ALLOC_FLAGS.
>> Evidently I'm not explaining myself well, I'll try again in more detail.
>>
>> We've got 2 sets of allocation flags in systemtap:
>>
>> STP_ALLOC_FLAGS: These are the default flags and allocations using this
>> set of flags will not sleep.
>>
>> STP_ALLOC_SLEEP_FLAGS: These flags are only supposed to be used from
>> contexts where it is safe to sleep (like begin probes).
>>
>> Here's the big question - on the realtime kernel, is it ever safe to
>> sleep?
>>
>> If the answer to the previous question is "no", then your change is
>> correct.
>>
>> If the answer to the previous question is "yes", then your change isn't
>> correct. Instead, we need to look at uses of STP_ALLOC_SLEEP_FLAGS,
>> because we're using the wrong set of flags somewhere. We're using
>> STP_ALLOC_SLEEP_FLAGS in an allocation that should be using
>> STP_ALLOC_FLAGS.
>>
>> I see 6 uses of STP_ALLOC_SLEEP_FLAGS in the systemtap source. If we
>> can't get a backtrace, then I'll need you to change the 6 uses of
>> STP_ALLOC_SLEEP_FLAGS to STP_ALLOC_FLAGS one at a time to figure out
>> which use of STP_ALLOC_SLEEP_FLAGS isn't correct.
>>
>> Thanks for continuing to work this problem.
> Hi, All
> 
> OK. I will do.

I had an idea which might help. I've attached a patch that adds a call
to 'might_sleep()' to all the functions that use STP_ALLOC_SLEEP_FLAGS.
Hopefully that might help point out where the problem lies.

Please give it a try.

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

[-- Attachment #2: might_sleep.patch --]
[-- Type: text/x-patch, Size: 2077 bytes --]

diff --git a/runtime/linux/stat_runtime.h b/runtime/linux/stat_runtime.h
index 5e27026..9491a1c 100644
--- a/runtime/linux/stat_runtime.h
+++ b/runtime/linux/stat_runtime.h
@@ -48,6 +48,7 @@ static Stat _stp_stat_alloc(size_t stat_data_size)
 		return NULL;
 
 	/* Called from module_init, so user context, may sleep alloc. */
+	might_sleep();
 	st = _stp_kmalloc_gfp (sizeof(struct _Stat), STP_ALLOC_SLEEP_FLAGS);
 	if (st == NULL)
 		return NULL;
diff --git a/runtime/linux/stp_tracepoint.c b/runtime/linux/stp_tracepoint.c
index 33fe27a..95c4e95 100644
--- a/runtime/linux/stp_tracepoint.c
+++ b/runtime/linux/stp_tracepoint.c
@@ -80,6 +80,7 @@ int add_probe(struct tracepoint_entry *e, void *probe, void *data)
 	}
 	if (found)
 		return -EEXIST;
+	might_sleep();
 	p = _stp_kmalloc_gfp(sizeof(struct stp_tp_probe),
 			STP_ALLOC_SLEEP_FLAGS);
 	if (!p)
@@ -153,6 +154,7 @@ struct tracepoint_entry *add_tracepoint(const char *name)
 	 * Using kmalloc here to allocate a variable length element. Could
 	 * cause some memory fragmentation if overused.
 	 */
+	might_sleep();
 	e = _stp_kmalloc_gfp(sizeof(struct tracepoint_entry) + name_len,
 			STP_ALLOC_SLEEP_FLAGS);
 	if (!e)
diff --git a/runtime/task_finder_vma.c b/runtime/task_finder_vma.c
index f0a4db9..354d424 100644
--- a/runtime/task_finder_vma.c
+++ b/runtime/task_finder_vma.c
@@ -53,6 +53,7 @@ __stp_tf_vma_new_entry(void)
 	struct __stp_tf_vma_entry *entry;
 	size_t size = sizeof (struct __stp_tf_vma_entry);
 #ifdef CONFIG_UTRACE
+	might_sleep();
 	entry = (struct __stp_tf_vma_entry *) _stp_kmalloc_gfp(size,
                                                          STP_ALLOC_SLEEP_FLAGS);
 #else
@@ -78,8 +79,11 @@ static int
 stap_initialize_vma_map(void)
 {
 	size_t size = sizeof(struct hlist_head) * __STP_TF_TABLE_SIZE;
-	struct hlist_head *map = (struct hlist_head *) _stp_kzalloc_gfp(size,
-							STP_ALLOC_SLEEP_FLAGS);
+	struct hlist_head *map;
+
+	might_sleep();
+	map = (struct hlist_head *) _stp_kzalloc_gfp(size,
+						     STP_ALLOC_SLEEP_FLAGS);
 	if (map == NULL)
 		return -ENOMEM;
 

  reply	other threads:[~2015-10-28 17:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-22  7:45 Zhu Yanjun
2015-10-22  7:53 ` yzhu1
2015-10-23  4:04   ` Santosh Shukla
2015-10-26  7:03     ` yzhu1
2015-10-26  8:25       ` yzhu1
2015-10-26  8:43         ` Santosh Shukla
2015-11-17  7:38     ` yzhu1
2015-11-17  7:52       ` Santosh Shukla
2015-10-22 16:34 ` David Smith
2015-10-26  3:19   ` yzhu1
2015-10-26 21:28     ` David Smith
2015-10-27 13:52       ` Frank Ch. Eigler
2015-10-28  2:30       ` yzhu1
2015-10-28 17:09         ` David Smith [this message]
2015-11-17  8:09 stp: rt: replace spin_lock with stp style lock and use yzhu1
2015-11-17  8:09 ` [PATCH 1/1] stp: rt: replace spin_lock with stp style lock and use STP_ALLOC_FLAGS yzhu1
2015-11-17 16:45   ` David Smith
2015-11-18  8:14     ` yzhu1
2015-11-18 17:14       ` David Smith
2015-11-19  7:53         ` yzhu1

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=5631014A.20202@redhat.com \
    --to=dsmith@redhat.com \
    --cc=Yanjun.Zhu@windriver.com \
    --cc=systemtap@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).