From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58453 invoked by alias); 28 Oct 2015 17:09:43 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 58444 invoked by uid 89); 28 Oct 2015 17:09:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 28 Oct 2015 17:09:40 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E31F08E3C0; Wed, 28 Oct 2015 17:09:38 +0000 (UTC) Received: from t540p.usersys.redhat.com (vpn-57-26.rdu2.redhat.com [10.10.57.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9SH9a7s018320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 Oct 2015 13:09:38 -0400 Subject: Re: [PATCH 1/1] stp: rt: replace spin_lock with stp style lock and use STP_ALLOC_FLAGS To: yzhu1 , systemtap@sourceware.org References: <1445499965-23777-1-git-send-email-yanjun.zhu@windriver.com> <56290FFC.3030407@redhat.com> <562D9BAA.7040704@windriver.com> <562E9AE0.6030501@redhat.com> <56303328.5030603@windriver.com> From: David Smith Message-ID: <5631014A.20202@redhat.com> Date: Wed, 28 Oct 2015 17:09:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56303328.5030603@windriver.com> Content-Type: multipart/mixed; boundary="------------040206000002070406010607" X-IsSubscribed: yes X-SW-Source: 2015-q4/txt/msg00076.txt.bz2 This is a multi-part message in MIME format. --------------040206000002070406010607 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-length: 1808 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) --------------040206000002070406010607 Content-Type: text/x-patch; name="might_sleep.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="might_sleep.patch" Content-length: 2077 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; --------------040206000002070406010607--