Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1598352rwb; Thu, 1 Dec 2022 21:07:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4LdQP2LBj9jggOO5pY/UQXNpZQBaYw+OguavfXc9llmUE04lJHFAnWKMncmUfgrdVqkhWy X-Received: by 2002:a05:6a02:118:b0:477:8106:b518 with SMTP id bg24-20020a056a02011800b004778106b518mr47420669pgb.106.1669957668512; Thu, 01 Dec 2022 21:07:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669957668; cv=none; d=google.com; s=arc-20160816; b=oXFgGQZ/o/jCSfzTX42lw98QndJenR5pkNAPvslNBiyrVGmHv+3MXOB4RLWt2zF8PL 1+nK6YeWnAozir0jJUT2gRf/g3rUzv1i2LQjcX3n4Ahwv3iHuoHOWOCCV7pyLZYTL1Ft b5vzEUb8WAIJUSvDlw6ZWhHmtz9NiV924TxX2gRoArzGLCCk0shF2oMgGs3SIQ1arY7T WKa2prxwwusw7ujBZU8MLQo8ZQMvUj0r7fWED50s2e5uY1CCwXT4U6k0/eUyMXnQvjm6 QwNZi5B9UdoT+2F4YBw9dY5i0q6dlMsLeC2COBQHpLvWldyn1lNDIcuLJ1roaTFbn5OQ ykqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Cvt49Jb9hFq3kpvt5uTOB833Q1dNKGEXrW84HbYVCv8=; b=Xl0sYMRWeAtjZYfh3GeQLHnETzGDzIPw2inekyMPtHB++Vxi8pemyBT8Kr4cGs4YoJ uP+6ffSQin9fv3+G47DDPDqe/HzOClDAgWe94UV1xxLDwfb7PRdvBcKXyDalTpsrVnws yGB34/1Yd38yt0wgTVLK6kR8ytn5oHAeJLqvzeUovG3MxQE7F6NHXBAix7XVFpThDiFf IvhKaesdUV9t72IwMtevkZI+mp16E/TOAScEXu63i5BqDYB2AMqDEEGh/otHfC+6yr6s d7CwsD45F6tJNYxX1XLYA13keK7Pzfhg+l3TaBEkvo92pV80whgw+evQvHoWg/sRP6MZ AOjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a63f752000000b00476f0b7d1f1si6384604pgk.804.2022.12.01.21.07.37; Thu, 01 Dec 2022 21:07:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231838AbiLBElC convert rfc822-to-8bit (ORCPT + 81 others); Thu, 1 Dec 2022 23:41:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbiLBElA (ORCPT ); Thu, 1 Dec 2022 23:41:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C690C9365; Thu, 1 Dec 2022 20:40:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2B941B8203C; Fri, 2 Dec 2022 04:40:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E07E9C433C1; Fri, 2 Dec 2022 04:40:55 +0000 (UTC) Date: Thu, 1 Dec 2022 23:40:52 -0500 From: Steven Rostedt To: Ira Weiny Cc: Dan Williams , Alison Schofield , Vishal Verma , "Ben Widawsky" , Jonathan Cameron , Davidlohr Bueso , "Dave Jiang" , , Subject: Re: [PATCH V2 02/11] cxl/mem: Implement Get Event Records command Message-ID: <20221201234052.35e5a001@gandalf.local.home> In-Reply-To: References: <20221201002719.2596558-1-ira.weiny@intel.com> <20221201002719.2596558-3-ira.weiny@intel.com> <20221201123849.0f7802ce@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 1 Dec 2022 16:09:17 -0800 Ira Weiny wrote: > Dropping that into cxlmem.h does not compile. I've given it another go but > because I use cxl_event_log_type_str() in a file where trace points are used > CREATE_TRACE_POINTS is defined and I get the following error. > > || drivers/cxl/core/mbox.c: In function ‘cxl_mem_get_records_log’: > drivers/cxl/cxlmem.h|386 col 7| error: implicit declaration of function ‘__print_symbolic’; did you mean ‘sprint_symbol’? [-Werror=implicit-function-declaration] > || 386 | __print_symbolic(type, \ > || | ^~~~~~~~~~~~~~~~ > > I got it to work with the patch below on top of this one.[3] But it is kind of > ugly. The only way I could get __print_symbolic() to be defined was to > redefine it in mbox.c.[1] Then throw it in it's own header as in [3] I played around a bit, and with the below patch, you can just have: #define cxl_event_log_type_str(type) \ __print_symbolic(type, \ { CXL_EVENT_TYPE_INFO, "Informational" }, \ { CXL_EVENT_TYPE_WARN, "Warning" }, \ { CXL_EVENT_TYPE_FAIL, "Failure" }, \ { CXL_EVENT_TYPE_FATAL, "Fatal" }) And everything else should "just work" :-) I can work on a more formal patch if this works for you. And thinking about this, perhaps we could add this throughout the kernel! -- Steve diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h index 00723935dcc7..ee41057674a2 100644 --- a/include/trace/define_trace.h +++ b/include/trace/define_trace.h @@ -132,4 +132,25 @@ /* We may be processing more files */ #define CREATE_TRACE_POINTS +#ifndef __DEFINE_PRINT_SYMBOLIC_STR +#define __DEFINE_PRINT_SYMBOLIC_STR +static inline const char * +__print_symbolic_str(int type, struct trace_print_flags *symbols) +{ + for (; symbols->name != NULL; symbols++) { + if (type == symbols->mask) + return symbols->name; + } + return ""; +} +#endif + +#undef __print_symbolic +#define __print_symbolic(value, symbol_array...) \ + ({ \ + static const struct trace_print_flags symbols[] = \ + { symbol_array, { -1, NULL }}; \ + __print_symbolic_str(value, symbols); \ + }) + #endif /* CREATE_TRACE_POINTS */ diff --git a/include/trace/stages/stage7_class_define.h b/include/trace/stages/stage7_class_define.h index 8a7ec24c246d..6fe83397f65d 100644 --- a/include/trace/stages/stage7_class_define.h +++ b/include/trace/stages/stage7_class_define.h @@ -6,7 +6,6 @@ #define __entry REC #undef __print_flags -#undef __print_symbolic #undef __print_hex #undef __print_hex_str #undef __get_dynamic_array