Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp100265ybg; Tue, 22 Oct 2019 16:53:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxolr2SF2dCcWwnAPow3ORxRjsca2jpgF9fuaYY+cp5F9fwf+IX5sRn659yDR13ZSrf6pF9 X-Received: by 2002:a05:6402:1b92:: with SMTP id cc18mr34925854edb.129.1571788419427; Tue, 22 Oct 2019 16:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571788419; cv=none; d=google.com; s=arc-20160816; b=uF7ZejwAnaIwhFld0upc2U6VRb4hr4qPJz83N6/cbgu/xYEomNkvHQCvpKy+961JhP aIOAjUSOOA1EUnWaObZ/on0ina0iUWp6ehfIpFDTEa8PDsoiuBdlbRyhJ5CwCDFwlI4I U5s3dZlsVt2yB9/PK7e8Dmwmt7IG82bws63S7NnTliu00O1aphLdnW8tJfYLVets03tS rpvaVbiNW+rRECshviva+YvBgGYlknvkSsbVZWI/ONgS/7CsXrDaEicIn2lKbqsDlYpO hBxSlnUQukxffjL5F78ksyuyfsrLSgyyb95GA+BBQQnn+dbdbRYF+RRD1fwYbU8hl66J JKgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Eqp/S2ULFEzOFb0uQBTmGTuzhqCrb9pJ5dgmrV/B/X8=; b=cLdq1ghL/Jjnh/aBPHDrsn9WkuNP2/TDcfkvU204T7StZySkgcJQc30nvM9fwbcMWi 4LbjyENe3a1W1KIFZvbdlPogTiI93Poxvx7K+SiM9zWsG6RVLSB1CsO5v+qRxHTkaJJo pt+nU4UThgZvj0ONMG9116AzpUeHViNKKF/tRyYl8dU6wljl4iKooXi95JUtXDa2sxIT M3JsKfzV4LX+TwRW46tif1fGVZefqT271UsU+3NM08A3piywVsucuB4Jm2tsbSeqoh8W zRaLyyXC/v697yr3DVmEQS4f/vu370eXtxtocp1BhdX4+OYoAuiG9zBdb4V7QJyj0BBd 2OrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (dns failure for signature) header.i=@infradead.org header.s=merlin.20170209 header.b=WVOHdLmC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si1850043ejr.417.2019.10.22.16.53.14; Tue, 22 Oct 2019 16:53:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (dns failure for signature) header.i=@infradead.org header.s=merlin.20170209 header.b=WVOHdLmC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388679AbfJVUYg (ORCPT + 99 others); Tue, 22 Oct 2019 16:24:36 -0400 Received: from merlin.infradead.org ([205.233.59.134]:42148 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388034AbfJVUYg (ORCPT ); Tue, 22 Oct 2019 16:24:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Eqp/S2ULFEzOFb0uQBTmGTuzhqCrb9pJ5dgmrV/B/X8=; b=WVOHdLmC4oHQW5nGU4X6rhC25 YdEro/pvxIlTU0UbuX9GbJS6MRg0llfqM5GliDb7OI6fn7fuj/A8qXfFzO0HEKmcyOnJgifh6OM/Z 5u80bhWZyh1GvQQnNY+wO0OKrCOyjMsW+zMBINp7aRGOSL5tOj/db4UAyFubJje3/RX/GsusMi1ZQ eiXFvsu5DLE2xiCl1sBAMyP3KLuZDFduNAc46Zo7AQlrtlNvA2ytodi1VRqeWZ17U2hSTCZwmXnSa +rpNno0tnq71SREsY/g/SU+pHgRnCnlBkkNQF8P4kBMlMdSI/2lzy0Q/FF/KeUZBt3+3FhjZJEAF9 M1upjwccA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iN0hJ-0003AR-3C; Tue, 22 Oct 2019 20:24:05 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id CB557300EBF; Tue, 22 Oct 2019 22:23:03 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 829AE2653949C; Tue, 22 Oct 2019 22:24:01 +0200 (CEST) Date: Tue, 22 Oct 2019 22:24:01 +0200 From: Peter Zijlstra To: Steven Rostedt Cc: x86@kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, bristot@redhat.com, jbaron@akamai.com, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, namit@vmware.com, hpa@zytor.com, luto@kernel.org, ard.biesheuvel@linaro.org, jpoimboe@redhat.com, jeyu@kernel.org Subject: Re: [PATCH v4 15/16] module: Move where we mark modules RO,X Message-ID: <20191022202401.GO1817@hirez.programming.kicks-ass.net> References: <20191018073525.768931536@infradead.org> <20191018074634.801435443@infradead.org> <20191021222110.49044eb5@oasis.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021222110.49044eb5@oasis.local.home> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 21, 2019 at 10:21:10PM -0400, Steven Rostedt wrote: > On Fri, 18 Oct 2019 09:35:40 +0200 > Peter Zijlstra wrote: > > > Now that set_all_modules_text_*() is gone, nothing depends on the > > relation between ->state = COMING and the protection state anymore. > > This enables moving the protection changes later, such that the COMING > > notifier callbacks can more easily modify the text. > > > > Signed-off-by: Peter Zijlstra (Intel) > > Cc: Jessica Yu > > --- > > This triggered the following bug: > > The trace_event_define_fields_() is defined in > include/trace/trace_events.h and is an init function called by the > trace_events event_create_dir() via the module notifier: > MODULE_STATE_COMING The below seems to cure it; and seems to generate identical events/*/format output (for my .config, with the exception of ID). It has just one section mismatch report that I'm too tired to look at just now. I'm not particularly proud of the "__function__" hack, but it works :/ I couldn't come up with anything else for [uk]probes which seem to have dynamic fields and if we're having it then syscall_enter can also make use of it, the syscall_metadata crud was going to be ugly otherwise. (also, win on LOC) --- fs/xfs/xfs_trace.h | 4 +- include/linux/trace_events.h | 16 ++++++- include/trace/events/filemap.h | 2 +- include/trace/trace_events.h | 64 ++++++++----------------- kernel/trace/trace.h | 31 ++++++------ kernel/trace/trace_entries.h | 66 +++++++------------------ kernel/trace/trace_events.c | 20 +++++++- kernel/trace/trace_export.c | 106 +++++++++++++++-------------------------- kernel/trace/trace_kprobe.c | 12 ++++- kernel/trace/trace_syscalls.c | 48 +++++++------------ kernel/trace/trace_uprobe.c | 6 ++- 11 files changed, 162 insertions(+), 213 deletions(-) diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index eaae275ed430..53c5485cf2a1 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -218,8 +218,8 @@ DECLARE_EVENT_CLASS(xfs_bmap_class, TP_STRUCT__entry( __field(dev_t, dev) __field(xfs_ino_t, ino) - __field(void *, leaf); - __field(int, pos); + __field(void *, leaf) + __field(int, pos) __field(xfs_fileoff_t, startoff) __field(xfs_fsblock_t, startblock) __field(xfs_filblks_t, blockcount) diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 30a8cdcfd4a4..30782e78b91d 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -187,6 +187,20 @@ enum trace_reg { struct trace_event_call; +struct trace_event_fields { + const char *type; + union { + struct { + const char *name; + const int size; + const int align; + const int is_signed; + const int filter_type; + }; + int (*define_fields)(struct trace_event_call *); + }; +}; + struct trace_event_class { const char *system; void *probe; @@ -195,7 +209,7 @@ struct trace_event_class { #endif int (*reg)(struct trace_event_call *event, enum trace_reg type, void *data); - int (*define_fields)(struct trace_event_call *); + struct trace_event_fields *fields_array; struct list_head *(*get_fields)(struct trace_event_call *); struct list_head fields; int (*raw_init)(struct trace_event_call *); diff --git a/include/trace/events/filemap.h b/include/trace/events/filemap.h index ee05db7ee8d2..796053e162d2 100644 --- a/include/trace/events/filemap.h +++ b/include/trace/events/filemap.h @@ -85,7 +85,7 @@ TRACE_EVENT(file_check_and_advance_wb_err, TP_ARGS(file, old), TP_STRUCT__entry( - __field(struct file *, file); + __field(struct file *, file) __field(unsigned long, i_ino) __field(dev_t, s_dev) __field(errseq_t, old) diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h index 4ecdfe2e3580..ca1d2e745a3f 100644 --- a/include/trace/trace_events.h +++ b/include/trace/trace_events.h @@ -394,22 +394,16 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \ #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) #undef __field_ext -#define __field_ext(type, item, filter_type) \ - ret = trace_define_field(event_call, #type, #item, \ - offsetof(typeof(field), item), \ - sizeof(field.item), \ - is_signed_type(type), filter_type); \ - if (ret) \ - return ret; +#define __field_ext(_type, _item, _filter_type) { \ + .type = #_type, .name = #_item, \ + .size = sizeof(_type), .align = __alignof__(_type), \ + .is_signed = is_signed_type(_type), .filter_type = _filter_type }, #undef __field_struct_ext -#define __field_struct_ext(type, item, filter_type) \ - ret = trace_define_field(event_call, #type, #item, \ - offsetof(typeof(field), item), \ - sizeof(field.item), \ - 0, filter_type); \ - if (ret) \ - return ret; +#define __field_struct_ext(_type, _item, _filter_type) { \ + .type = #_type, .name = #_item, \ + .size = sizeof(_type), .align = __alignof__(_type), \ + 0, .filter_type = _filter_type }, #undef __field #define __field(type, item) __field_ext(type, item, FILTER_OTHER) @@ -418,25 +412,16 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \ #define __field_struct(type, item) __field_struct_ext(type, item, FILTER_OTHER) #undef __array -#define __array(type, item, len) \ - do { \ - char *type_str = #type"["__stringify(len)"]"; \ - BUILD_BUG_ON(len > MAX_FILTER_STR_VAL); \ - BUILD_BUG_ON(len <= 0); \ - ret = trace_define_field(event_call, type_str, #item, \ - offsetof(typeof(field), item), \ - sizeof(field.item), \ - is_signed_type(type), FILTER_OTHER); \ - if (ret) \ - return ret; \ - } while (0); +#define __array(_type, _item, _len) { \ + .type = #_type"["__stringify(_len)"]", .name = #_item, \ + .size = sizeof(_type[_len]), .align = __alignof__(_type), \ + .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER }, #undef __dynamic_array -#define __dynamic_array(type, item, len) \ - ret = trace_define_field(event_call, "__data_loc " #type "[]", #item, \ - offsetof(typeof(field), __data_loc_##item), \ - sizeof(field.__data_loc_##item), \ - is_signed_type(type), FILTER_OTHER); +#define __dynamic_array(_type, _item, _len) { \ + .type = "__data_loc " #_type "[]", .name = #_item, \ + .size = 4, .align = 4, \ + .is_signed = is_signed_type(_type), .filter_type = FILTER_OTHER }, #undef __string #define __string(item, src) __dynamic_array(char, item, -1) @@ -446,16 +431,9 @@ static struct trace_event_functions trace_event_type_funcs_##call = { \ #undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, func, print) \ -static int notrace __init \ -trace_event_define_fields_##call(struct trace_event_call *event_call) \ -{ \ - struct trace_event_raw_##call field; \ - int ret; \ - \ - tstruct; \ - \ - return ret; \ -} +static struct trace_event_fields trace_event_fields_##call[] = { \ + tstruct \ + {} }; #undef DEFINE_EVENT #define DEFINE_EVENT(template, name, proto, args) @@ -613,7 +591,7 @@ static inline notrace int trace_event_get_offsets_##call( \ * * static struct trace_event_class __used event_class_