Message ID | 20230930203213.826737400@goodmis.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp569314vqb; Sat, 30 Sep 2023 13:38:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGabbb0J+o8np2OBoWuuN64RGZqSxfmtYNv+z4JQYeWM5YRRiTSVU/XM7lMWqleuzxFi7aY X-Received: by 2002:a9d:6289:0:b0:6c4:c026:a658 with SMTP id x9-20020a9d6289000000b006c4c026a658mr7955582otk.26.1696106309098; Sat, 30 Sep 2023 13:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696106309; cv=none; d=google.com; s=arc-20160816; b=TuA8KkY17uQAMeitP6xsDUyxU50rtXFjleFXgDt6zaN6ilvtjAExyKGdQIOjEWRFBl sUhLM2Uac5YgTnNe9mGnUQvg+LqztuDTUnbNMt++1ABYYY7Y57jwwqrB5kifgvRWb5+b On4D0vo0htQXQk62xZS6QXkX41tSsGU11OyaGRZpJYlL6FuV/qaAwC6TX+wI6EnLjUrx 2BxsRtwahrpqUX1cs/B77JYq+Gj2tsvba49u2D3Om9ynn0coXYzIvfERWsC6z5Qd1mmk L1Qk6aqRudJlwup3FedickEsxsdUxU+OKVeSl3hwo4g0BHZeJpaeiLyirwS503h81EPn vB4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:user-agent:message-id; bh=h6SdLVsMaHQfU2JD058xNYNe8berULcbUYQsVDiR27c=; fh=cY9HGbp9RiQ9xCYqjybSe1/cIiXVFs0Cn9z6ge1iyyY=; b=De/1mAN3h7LbjbdPWhiWjOamAUemqOF0HDPFmnaDmbsqhBXoKl15cgHvya4VpvHT7C 1KN2Q1yPnTcAIDxfT26RiSdEX6RnC2PA2KXzSzi8E3Ik8rwv2bvFkYAuvwKhSw4XsRzs lhvJFlhP2lLTNJ+n/VgKNzvukHrEGXy5VbcEg4M1SphLhrfNtCFIjg03AzAAlA0Y1mWB DdSmtio3lcX5BGOVjbGi0mtWERpDzQqeoAOU5ePTTJ85WD/bZuj84ZBe0AmaQVVF5TWD 2NK3XjaPA1kgjCU5TLdAUptvVpMa57H6j39QGyFZ22doGJDy+Uv2/RvX6gHOAg+XL/oi hmrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id n22-20020a63f816000000b0056f7592d732si23415551pgh.424.2023.09.30.13.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 13:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A64FE819E4FE; Sat, 30 Sep 2023 13:37:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232155AbjI3UhZ (ORCPT <rfc822;chrisfriedt@gmail.com> + 20 others); Sat, 30 Sep 2023 16:37:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjI3UhY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 30 Sep 2023 16:37:24 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E301C4 for <linux-kernel@vger.kernel.org>; Sat, 30 Sep 2023 13:37:22 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CE71C433C7; Sat, 30 Sep 2023 20:37:22 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.96) (envelope-from <rostedt@goodmis.org>) id 1qmgjF-004Myu-1G; Sat, 30 Sep 2023 16:38:21 -0400 Message-ID: <20230930203213.826737400@goodmis.org> User-Agent: quilt/0.66 Date: Sat, 30 Sep 2023 16:32:13 -0400 From: Steven Rostedt <rostedt@goodmis.org> To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu <mhiramat@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Andrew Morton <akpm@linux-foundation.org> Subject: [for-linus][PATCH 0/4] tracing: Fixes for v6.6-rc3 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,PP_MIME_FAKE_ASCII_TEXT,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 30 Sep 2023 13:37:36 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778496368708140104 X-GMAIL-MSGID: 1778496368708140104 |
Series |
tracing: Fixes for v6.6-rc3
|
|
Message
Steven Rostedt
Sept. 30, 2023, 8:32 p.m. UTC
Tracing fixes for v6.6-rc3: - Make sure 32 bit applications using user events have aligned access when running on a 64 bit kernel. - Add cond_resched in the loop that handles converting enums in print_fmt string is trace events. - Fix premature wake ups of polling processes in the tracing ring buffer. When a task polls waiting for a percentage of the ring buffer to be filled, the writer still will wake it up at every event. Add the polling's percentage to the "shortest_full" list to tell the writer when to wake it up. - For eventfs dir lookups on dynamic events, an event system's only event could be removed, leaving its dentry with no children. This is totally legitimate. But on eventfs_release() it must not access the children array, as it is only allocated when the dentry has children. git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace/urgent Head SHA1: 2598bd3ca8dcf5bbca1161ee5b271b432398da37 Beau Belgrave (1): tracing/user_events: Align set_bit() address for all archs Clément Léger (1): tracing: relax trace_event_eval_update() execution with cond_resched() Steven Rostedt (Google) (2): ring-buffer: Update "shortest_full" in polling eventfs: Test for dentries array allocated in eventfs_release() ---- fs/tracefs/event_inode.c | 2 +- kernel/trace/ring_buffer.c | 3 +++ kernel/trace/trace_events.c | 1 + kernel/trace/trace_events_user.c | 58 +++++++++++++++++++++++++++++++++++----- 4 files changed, 56 insertions(+), 8 deletions(-)
Comments
[ The problem with sending email with quilt. It doesn't handle UTF-8 well :-/ ] On Sat, 30 Sep 2023 16:32:15 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= <cleger@rivosinc.com> > > When kernel is compiled without preemption, the eval_map_work_func() > (which calls trace_event_eval_update()) will not be preempted up to its > complete execution. This can actually cause a problem since if another > CPU call stop_machine(), the call will have to wait for the > eval_map_work_func() function to finish executing in the workqueue > before being able to be scheduled. This problem was observe on a SMP > system at boot time, when the CPU calling the initcalls executed > clocksource_done_booting() which in the end calls stop_machine(). We > observed a 1 second delay because one CPU was executing > eval_map_work_func() and was not preempted by the stop_machine() task. > > Adding a call to cond_resched() in trace_event_eval_update() allows > other tasks to be executed and thus continue working asynchronously > like before without blocking any pending task at boot time. > > Link: https://lore.kernel.org/linux-trace-kernel/20230929191637.416931-1-cleger@rivosinc.com > > Cc: Masami Hiramatsu <mhiramat@kernel.org> > Signed-off-by: Clément Léger <cleger@rivosinc.com> > Tested-by: Atish Patra <atishp@rivosinc.com> > Reviewed-by: Atish Patra <atishp@rivosinc.com> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> > --- > kernel/trace/trace_events.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c > index 91951d038ba4..f49d6ddb6342 100644 > --- a/kernel/trace/trace_events.c > +++ b/kernel/trace/trace_events.c > @@ -2770,6 +2770,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len) > update_event_fields(call, map[i]); > } > } > + cond_resched(); > } > up_write(&trace_event_sem); > }
[ Replying to show this patch that got dropped from the mailing list ] On Sat, 30 Sep 2023 16:32:16 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > From: Beau Belgrave <beaub@linux.microsoft.com> > > All architectures should use a long aligned address passed to set_bit(). > User processes can pass either a 32-bit or 64-bit sized value to be > updated when tracing is enabled when on a 64-bit kernel. Both cases are > ensured to be naturally aligned, however, that is not enough. The > address must be long aligned without affecting checks on the value > within the user process which require different adjustments for the bit > for little and big endian CPUs. > > Add a compat flag to user_event_enabler that indicates when a 32-bit > value is being used on a 64-bit kernel. Long align addresses and correct > the bit to be used by set_bit() to account for this alignment. Ensure > compat flags are copied during forks and used during deletion clears. > > Link: https://lore.kernel.org/linux-trace-kernel/20230925230829.341-2-beaub@linux.microsoft.com > Link: https://lore.kernel.org/linux-trace-kernel/20230914131102.179100-1-cleger@rivosinc.com/ > > Cc: stable@vger.kernel.org > Fixes: 7235759084a4 ("tracing/user_events: Use remote writes for event enablement") > Reported-by: Clément Léger <cleger@rivosinc.com> > Suggested-by: Clément Léger <cleger@rivosinc.com> > Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> > --- > kernel/trace/trace_events_user.c | 58 ++++++++++++++++++++++++++++---- > 1 file changed, 51 insertions(+), 7 deletions(-) > > diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c > index 6f046650e527..b87f41187c6a 100644 > --- a/kernel/trace/trace_events_user.c > +++ b/kernel/trace/trace_events_user.c > @@ -127,8 +127,13 @@ struct user_event_enabler { > /* Bit 7 is for freeing status of enablement */ > #define ENABLE_VAL_FREEING_BIT 7 > > -/* Only duplicate the bit value */ > -#define ENABLE_VAL_DUP_MASK ENABLE_VAL_BIT_MASK > +/* Bit 8 is for marking 32-bit on 64-bit */ > +#define ENABLE_VAL_32_ON_64_BIT 8 > + > +#define ENABLE_VAL_COMPAT_MASK (1 << ENABLE_VAL_32_ON_64_BIT) > + > +/* Only duplicate the bit and compat values */ > +#define ENABLE_VAL_DUP_MASK (ENABLE_VAL_BIT_MASK | ENABLE_VAL_COMPAT_MASK) > > #define ENABLE_BITOPS(e) (&(e)->values) > > @@ -174,6 +179,30 @@ struct user_event_validator { > int flags; > }; > > +static inline void align_addr_bit(unsigned long *addr, int *bit, > + unsigned long *flags) > +{ > + if (IS_ALIGNED(*addr, sizeof(long))) { > +#ifdef __BIG_ENDIAN > + /* 32 bit on BE 64 bit requires a 32 bit offset when aligned. */ > + if (test_bit(ENABLE_VAL_32_ON_64_BIT, flags)) > + *bit += 32; > +#endif > + return; > + } > + > + *addr = ALIGN_DOWN(*addr, sizeof(long)); > + > + /* > + * We only support 32 and 64 bit values. The only time we need > + * to align is a 32 bit value on a 64 bit kernel, which on LE > + * is always 32 bits, and on BE requires no change when unaligned. > + */ > +#ifdef __LITTLE_ENDIAN > + *bit += 32; > +#endif > +} > + > typedef void (*user_event_func_t) (struct user_event *user, struct iov_iter *i, > void *tpdata, bool *faulted); > > @@ -482,6 +511,7 @@ static int user_event_enabler_write(struct user_event_mm *mm, > unsigned long *ptr; > struct page *page; > void *kaddr; > + int bit = ENABLE_BIT(enabler); > int ret; > > lockdep_assert_held(&event_mutex); > @@ -497,6 +527,8 @@ static int user_event_enabler_write(struct user_event_mm *mm, > test_bit(ENABLE_VAL_FREEING_BIT, ENABLE_BITOPS(enabler)))) > return -EBUSY; > > + align_addr_bit(&uaddr, &bit, ENABLE_BITOPS(enabler)); > + > ret = pin_user_pages_remote(mm->mm, uaddr, 1, FOLL_WRITE | FOLL_NOFAULT, > &page, NULL); > > @@ -515,9 +547,9 @@ static int user_event_enabler_write(struct user_event_mm *mm, > > /* Update bit atomically, user tracers must be atomic as well */ > if (enabler->event && enabler->event->status) > - set_bit(ENABLE_BIT(enabler), ptr); > + set_bit(bit, ptr); > else > - clear_bit(ENABLE_BIT(enabler), ptr); > + clear_bit(bit, ptr); > > kunmap_local(kaddr); > unpin_user_pages_dirty_lock(&page, 1, true); > @@ -849,6 +881,12 @@ static struct user_event_enabler > enabler->event = user; > enabler->addr = uaddr; > enabler->values = reg->enable_bit; > + > +#if BITS_PER_LONG >= 64 > + if (reg->enable_size == 4) > + set_bit(ENABLE_VAL_32_ON_64_BIT, ENABLE_BITOPS(enabler)); > +#endif > + > retry: > /* Prevents state changes from racing with new enablers */ > mutex_lock(&event_mutex); > @@ -2377,7 +2415,8 @@ static long user_unreg_get(struct user_unreg __user *ureg, > } > > static int user_event_mm_clear_bit(struct user_event_mm *user_mm, > - unsigned long uaddr, unsigned char bit) > + unsigned long uaddr, unsigned char bit, > + unsigned long flags) > { > struct user_event_enabler enabler; > int result; > @@ -2385,7 +2424,7 @@ static int user_event_mm_clear_bit(struct user_event_mm *user_mm, > > memset(&enabler, 0, sizeof(enabler)); > enabler.addr = uaddr; > - enabler.values = bit; > + enabler.values = bit | flags; > retry: > /* Prevents state changes from racing with new enablers */ > mutex_lock(&event_mutex); > @@ -2415,6 +2454,7 @@ static long user_events_ioctl_unreg(unsigned long uarg) > struct user_event_mm *mm = current->user_event_mm; > struct user_event_enabler *enabler, *next; > struct user_unreg reg; > + unsigned long flags; > long ret; > > ret = user_unreg_get(ureg, ®); > @@ -2425,6 +2465,7 @@ static long user_events_ioctl_unreg(unsigned long uarg) > if (!mm) > return -ENOENT; > > + flags = 0; > ret = -ENOENT; > > /* > @@ -2441,6 +2482,9 @@ static long user_events_ioctl_unreg(unsigned long uarg) > ENABLE_BIT(enabler) == reg.disable_bit) { > set_bit(ENABLE_VAL_FREEING_BIT, ENABLE_BITOPS(enabler)); > > + /* We must keep compat flags for the clear */ > + flags |= enabler->values & ENABLE_VAL_COMPAT_MASK; > + > if (!test_bit(ENABLE_VAL_FAULTING_BIT, ENABLE_BITOPS(enabler))) > user_event_enabler_destroy(enabler, true); > > @@ -2454,7 +2498,7 @@ static long user_events_ioctl_unreg(unsigned long uarg) > /* Ensure bit is now cleared for user, regardless of event status */ > if (!ret) > ret = user_event_mm_clear_bit(mm, reg.disable_addr, > - reg.disable_bit); > + reg.disable_bit, flags); > > return ret; > }