From patchwork Sat Mar 11 03:14:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 67964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp96878wrd; Fri, 10 Mar 2023 19:16:45 -0800 (PST) X-Google-Smtp-Source: AK7set/HLY4Z0L42TocO/HR6GSAAU/4QGMn9gwflRvWEYAOJms+ge8N2oU/qdPY8NT/Gapa8HSH0 X-Received: by 2002:a05:6a20:6a9e:b0:cd:71de:e757 with SMTP id bi30-20020a056a206a9e00b000cd71dee757mr23185280pzb.32.1678504604775; Fri, 10 Mar 2023 19:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678504604; cv=none; d=google.com; s=arc-20160816; b=hDMYS+RPqpuZyO1S/Ix4668Fer8Z7P8RviCaOFzVYLzlZ8r/y+ibu5GETg0h1SDkvH /KrtLZUf6XKV5igj5nix0CNGSOv93Xjhsdlie7R4P0j9wPzYKnvNN3qGuQygmXXL2QY8 kIlAJnGR0UvucjQ3uEu3wGdyMU1iQSd68rwbjIJXv4rPN0anM0FN5VV3EFZ+nMURzLmF ZxN6aSvjX/qJD7A3X0HakRbUd+Ho8b97luxidXqJT0XbVzI2D8yBP4S2YwOVKOJ6wf2+ YOSuKqeMPkDCaQsFYBRZlVvUkyuPERzr5HShAygVgJacm/Y5LG/dSS4Iq9WoeGzruo46 t7Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:dkim-signature :from; bh=NhMloEUhXeNoCJ+v5Ympozzt8Z64+8fkC2CgIEukKLU=; b=WH1b/YuqUmVpapKl4PEbG8UOHxVxb2v87BTKMn23kVlOKrENsGvnRsQCjZB9fNn7Zi /k+j61QoH4jrjEl/HvwAFEVkLVeVGrtf4S5cvA4M96VEZ82kVAiYkwgHgTTp8SBb6Zsa cYC1IObM3oTOgAMF6vnfmQSY1dcyZW72le5JKbrP9h249ybBIDuuPkrAewiAXQkIa0eW RmTmU0mEzNnBg4jzyiNZL0p77WuXg3bj08ZQSqaYeqA5nS8P4RcGTypQMeq7KJnSfJQs oXNaHKxEWiBnRLgwO5gahW4BRIDB6M+dr45WMuWWNl8hXvDzVVLAPgJiwgLH0f+2bLCu 3DHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="Zuk3/bEc"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d65-20020a621d44000000b005a8c0f03340si1093519pfd.375.2023.03.10.19.16.31; Fri, 10 Mar 2023 19:16:44 -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; dkim=pass header.i=@weissschuh.net header.s=mail header.b="Zuk3/bEc"; 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 S229757AbjCKDPB (ORCPT + 99 others); Fri, 10 Mar 2023 22:15:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjCKDO7 (ORCPT ); Fri, 10 Mar 2023 22:14:59 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10798132A94 for ; Fri, 10 Mar 2023 19:14:57 -0800 (PST) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1678504495; bh=7UpojwGw4Wjc6iwDTG11oJXV5hBbJObX8sfOzw0j3+8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Zuk3/bEco0V/MQXZlAcAPaRUfq7PBCyCHrQ5lII+Ejk8k5muVy2a8j2D9o65dIe4F SN5qJxczydCRpCvjAZlU61FElYRahnllDt3phpk2ftEsX3DwthmRQCWOpaC0HIJJ0W fojPpoCxInntp/Jpzl3pMUswSsbdVq9HDcIg5YR8= Date: Sat, 11 Mar 2023 03:14:46 +0000 Subject: [PATCH 1/4] kobject: define common logging prefix MIME-Version: 1.0 Message-Id: <20230311-kobject-warning-v1-1-1ebba4f71fb5@weissschuh.net> References: <20230311-kobject-warning-v1-0-1ebba4f71fb5@weissschuh.net> In-Reply-To: <20230311-kobject-warning-v1-0-1ebba4f71fb5@weissschuh.net> To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1678504493; l=4592; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=7UpojwGw4Wjc6iwDTG11oJXV5hBbJObX8sfOzw0j3+8=; b=srn5/5x4qNccxjCHSdFcj5F169tzEJq4pb0s/zWHAQ8IsN85mklJg4gN9ClW7E8LNGFsu+m19 eUbb4wQJLKgA94beuVi7iaIN2+Jx8vzhVXebWmGchzayQCZ7O5c8qIg X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760039644427158044?= X-GMAIL-MSGID: =?utf-8?q?1760039644427158044?= All log messages start with the prefix "kobject: ". Deduplicate this by using the pr_fmt() facility. This makes the very long log strings shorter. Signed-off-by: Thomas Weißschuh --- lib/kobject.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/kobject.c b/lib/kobject.c index 6e2f0bee3560..09c81ffb8b33 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -10,6 +10,8 @@ * about using the kobject interface. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -127,7 +129,7 @@ static int fill_kobj_path(const struct kobject *kobj, char *path, int length) *(path + --length) = '/'; } - pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj), + pr_debug("'%s' (%p): %s: path = '%s'\n", kobject_name(kobj), kobj, __func__, path); return 0; @@ -223,7 +225,7 @@ static int kobject_add_internal(struct kobject *kobj) kobj->parent = parent; } - pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", + pr_debug("'%s' (%p): %s: parent: '%s', set: '%s'\n", kobject_name(kobj), kobj, __func__, parent ? kobject_name(parent) : "", kobj->kset ? kobject_name(&kobj->kset->kobj) : ""); @@ -359,7 +361,7 @@ static __printf(3, 0) int kobject_add_varg(struct kobject *kobj, retval = kobject_set_name_vargs(kobj, fmt, vargs); if (retval) { - pr_err("kobject: can not set name properly!\n"); + pr_err("can not set name properly!\n"); return retval; } kobj->parent = parent; @@ -588,7 +590,7 @@ static void __kobject_del(struct kobject *kobj) /* send "remove" if the caller did not do it but sent "add" */ if (kobj->state_add_uevent_sent && !kobj->state_remove_uevent_sent) { - pr_debug("kobject: '%s' (%p): auto cleanup 'remove' event\n", + pr_debug("'%s' (%p): auto cleanup 'remove' event\n", kobject_name(kobj), kobj); kobject_uevent(kobj, KOBJ_REMOVE); } @@ -658,16 +660,16 @@ static void kobject_cleanup(struct kobject *kobj) const struct kobj_type *t = get_ktype(kobj); const char *name = kobj->name; - pr_debug("kobject: '%s' (%p): %s, parent %p\n", + pr_debug("'%s' (%p): %s, parent %p\n", kobject_name(kobj), kobj, __func__, kobj->parent); if (t && !t->release) - pr_debug("kobject: '%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", + pr_debug("'%s' (%p): does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.\n", kobject_name(kobj), kobj); /* remove from sysfs if the caller did not do it */ if (kobj->state_in_sysfs) { - pr_debug("kobject: '%s' (%p): auto cleanup kobject_del\n", + pr_debug("'%s' (%p): auto cleanup kobject_del\n", kobject_name(kobj), kobj); __kobject_del(kobj); } else { @@ -676,14 +678,14 @@ static void kobject_cleanup(struct kobject *kobj) } if (t && t->release) { - pr_debug("kobject: '%s' (%p): calling ktype release\n", + pr_debug("'%s' (%p): calling ktype release\n", kobject_name(kobj), kobj); t->release(kobj); } /* free name if we allocated it */ if (name) { - pr_debug("kobject: '%s': free name\n", name); + pr_debug("'%s': free name\n", name); kfree_const(name); } @@ -703,8 +705,8 @@ static void kobject_release(struct kref *kref) struct kobject *kobj = container_of(kref, struct kobject, kref); #ifdef CONFIG_DEBUG_KOBJECT_RELEASE unsigned long delay = HZ + HZ * get_random_u32_below(4); - pr_info("kobject: '%s' (%p): %s, parent %p (delayed %ld)\n", - kobject_name(kobj), kobj, __func__, kobj->parent, delay); + pr_info("'%s' (%p): %s, parent %p (delayed %ld)\n", + kobject_name(kobj), kobj, __func__, kobj->parent, delay); INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup); schedule_delayed_work(&kobj->release, delay); @@ -733,7 +735,7 @@ EXPORT_SYMBOL(kobject_put); static void dynamic_kobj_release(struct kobject *kobj) { - pr_debug("kobject: (%p): %s\n", kobj, __func__); + pr_debug("(%p): %s\n", kobj, __func__); kfree(kobj); } @@ -910,7 +912,7 @@ EXPORT_SYMBOL_GPL(kset_find_obj); static void kset_release(struct kobject *kobj) { struct kset *kset = container_of(kobj, struct kset, kobj); - pr_debug("kobject: '%s' (%p): %s\n", + pr_debug("'%s' (%p): %s\n", kobject_name(kobj), kobj, __func__); kfree(kset); }