From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20E24C433B4 for ; Tue, 11 May 2021 18:52:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A0E3C61185 for ; Tue, 11 May 2021 18:52:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0E3C61185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 21CA76B009E; Tue, 11 May 2021 14:51:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A9016B009F; Tue, 11 May 2021 14:51:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0F8A6B00A0; Tue, 11 May 2021 14:51:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id CE4136B009E for ; Tue, 11 May 2021 14:51:56 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8481A180275CC for ; Tue, 11 May 2021 18:51:56 +0000 (UTC) X-FDA: 78129844632.36.CB48FF8 Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by imf12.hostedemail.com (Postfix) with ESMTP id 0F366F9 for ; Tue, 11 May 2021 18:51:39 +0000 (UTC) Received: by mail-il1-f174.google.com with SMTP id j20so18029129ilo.10 for ; Tue, 11 May 2021 11:51:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RetV73+gjmatQ10AYA8JVaODMFVKb7GL6Z0yeYfciDg=; b=fRIuCpEZT5toBeJSxRcZygcC8hRLmM9HlDEtdBqsGTt4k5QJA4Puu2+YFFwsLKN7/5 mdNeZJmc0P8fhWS43um5qEISx4cqn/3thn0zsUihATIkz8KQ8EtSRchQw8Iy7l0JpeDV 6mLurHEdKhFjq+GZN6mKsu2ypF8V9dYG+z3AFIO4AlmmoVfEwYVVbwHx8YrkLzeTPS14 23X0nd4gEH/uyaYaZZfAqITHS4j9FkmOe23MWa/cvxlNZsjzSFg33Qn09/FEQ3iza0Fu lsj3CHOeAaS0rGbviepfMq0SxifOyC6rvKnV42TEyYGLYjWzRihoWlidLK0GS22CXTKP UjBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RetV73+gjmatQ10AYA8JVaODMFVKb7GL6Z0yeYfciDg=; b=ecD0diASsPh6Ew+IimTjmFRACPoSRDZFEcWNs6ulqTcoDjRvTt8SUBRb4HQnSXHhUA u7tF94B+ztvbElwqDDFmFV7c4+Hs3b+s900/x4qHfsGZOomPAjgYH+uqzOyWZGIOFIE1 UVjZ1NB/9qV2GjdoUkS8t1H507XVoWkc70XW8L6mK1btC1Nk8JBf65AHTPpp/0iw5IiV eOUaCH+qGzQU5ID33tljcwGTM1MxisfNaTxlyci1VAty0EAGUMMmq2tMAzLvkpCCqFBc nYsgDG5z1nYl8jI01KZjmwMufqS12pe/Qo5565Jwt9uka0kS9I0FGf6F2g5Vt4F4qRmy wGtA== X-Gm-Message-State: AOAM5312ZhorA0Vm8/pLC0MkMFRr40/a3WREs8jQ0Lhra3SyFsGPIl2v z9N0WnISS1P0WI0fiKxDHak= X-Google-Smtp-Source: ABdhPJxqhsB2v+ubkXoKuKBuZ58V3W7JR1ZIHk3WyB51m5HA5YvDAVqhizjZsfGdclze8KcHYlAwiA== X-Received: by 2002:a92:1a12:: with SMTP id a18mr27991241ila.168.1620759115477; Tue, 11 May 2021 11:51:55 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:55 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 27/28] dyndbg: unionize _ddebug*_headers with struct _ddebug* Date: Tue, 11 May 2021 12:50:56 -0600 Message-Id: <20210511185057.3815777-28-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0F366F9 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=fRIuCpEZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of jimcromie@gmail.com designates 209.85.166.174 as permitted sender) smtp.mailfrom=jimcromie@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: 8w4p7mhomxmd1hwa3e9hppkt1619n8m6 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail-il1-f174.google.com; client-ip=209.85.166.174 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620759099-551653 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Up until now, to create our header record (pair), we reused struct _ddebug(|_sites), initializing the pair with "impossible" field values (for a pr_debug() site), which makes it recognizable as a header not a pr-debug callsite. Now we want to specialize the header; differentiate it from its model, then we can drop _ddebug.site, and use header.site indirectly. This commit has several elements combining: Update DEFINE_DYNAMIC_DEBUG_TABLE by replacing "struct _ddebug*" with "union _ddebug*_header". This change places the new object types into our 2 elf sections. our 2 new union types have 2 jobs: a.fit properly in the section/array. We do this by putting the struct inside the union, making the unions the same size as their contained structs. This was sufficient to fix a data-misalignment crash on 2nd loop (ie 1st record after header) in _init. b.unions need the same field defns as their models, as refd in: DEFINE_DYNAMIC_DEBUG_TABLE() - inits is_dyndbg_header_pair(i,s) - validates that init use anonymous struct. RFC: My "anonymous union/struct fu" feels incomplete. The struct in b must contain all the fields of its outer union's own contained struct, maybe even in the same order (tho not obvious yet). Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.= h index 46901b5348ee..9ca413985fb2 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -36,6 +36,16 @@ struct _ddebug_site { const char *function; } __aligned(8); =20 +/* verbatim copy of struct _ddebug_site. nothing to save here. */ +union _ddebug_site_header { + struct _ddebug_site __; /* inherit footprint */ + struct { /* header validation */ + const char *modname; + const char *filename; + const char *function; + }; +}; + struct _ddebug { SITE_CHK_(struct _ddebug_site *site;) /* format is always needed, lineno shares word with flags */ @@ -74,6 +84,21 @@ struct _ddebug { #endif } __aligned(8); =20 +/* + * specialized version of struct _ddebug. The only field we NEED is + * .site, since keeping it here allows dropping from struct _ddebug + * itself. format, lineno are used to validate header records. + */ +union _ddebug_header { + struct _ddebug __; /* inherit footprint */ + struct { /* header validation */ + union _ddebug_site_header *site; + const char *format; + const unsigned lineno:18; + unsigned _index:14; + unsigned int flags:8; + }; +}; =20 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) =20 @@ -136,10 +161,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor= , */ #define DEFINE_DYNAMIC_DEBUG_TABLE() \ /* forward decl, allowing loopback pointer */ \ - __weak struct _ddebug __used __aligned(8) \ + __weak union _ddebug_header __used __aligned(8) \ __section(".gnu.linkonce.dyndbg") \ _LINKONCE_dyndbg_header; \ - __weak struct _ddebug_site __used __aligned(8) \ + __weak union _ddebug_site_header __used __aligned(8) \ __section(".gnu.linkonce.dyndbg_site") \ _LINKONCE_dyndbg_site_header =3D { \ .modname =3D KBUILD_MODNAME, \ @@ -147,7 +172,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, /* forced pointer loopback, for distinction */ \ .filename =3D (void *) &_LINKONCE_dyndbg_header \ }; \ - __weak struct _ddebug __used __aligned(8) \ + __weak union _ddebug_header __used __aligned(8) \ __section(".gnu.linkonce.dyndbg") \ _LINKONCE_dyndbg_header =3D { \ SITE_INIT_(_LINKONCE_dyndbg_site_header) \ --=20 2.31.1