Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp976760lqe; Sun, 7 Apr 2024 12:33:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuzSw8kZUhuz/pf1nG9ZWLAvmtx2jHKnYYGxt+QCV19r138CCHfQ0fHcFBZKw4djJKzdAUlDvticTwFbobfbJVSaoJ6wpC0oJwbqPmBw== X-Google-Smtp-Source: AGHT+IGkiHSTGoAdmB+MVjM7IdlobRRQCubDlJJiNda1oYCLwu3O4vG01264ldW3vffrX8PPCPNN X-Received: by 2002:a19:5e51:0:b0:516:a18f:872e with SMTP id z17-20020a195e51000000b00516a18f872emr5221650lfi.38.1712518381103; Sun, 07 Apr 2024 12:33:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712518381; cv=pass; d=google.com; s=arc-20160816; b=oguwz9n+gBCV3ObplDG2FhFfj0D3kYptjr7KcGbnhaNwf9Da0GLrG+tX98eyTvFWVg Zo0oUu78Gz34QmMA9uPmWF0I3MMK8IT691upwlVoJZcoGvS3QD0lH/ph7j9eLXf5qRL4 zQze2NF8dymjON4EFt3/t6EQyL9nlDD4Hm5z6+8pQQVtVyQ9u/H+1JMx4RCAf5rzuifM 4/ABYveH4xGvHJv4bKZC+ApuZw3lkuULQiVseaPAOEFuHENnZuQ14jCVvLPUsZMZmx+B yCtasYd/L8z6gyfNqRqWNrr/aA+pl4bzO+TnFrvv1PvPvDt6BjH3dAL8R86CgnFMJBqo Kf+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=MLm6iC4WNTdIn+XgL/qIwT01bSJfAFu6/aMBhdI31mM=; fh=8q1VOhB/F0WXkrF/PX1hwB3PpCmKXnEerBs3GXS9hm8=; b=yZ3weE8N3LcDoPJotA0Az+VfAmZbmGyLJAnN7HIuybj3zak88+Qx9rJnT67GSKgNoB zx0A12cN/qRC7BkhqxCEpqXiziffVlYePJkyR+T7gSZCnPkNyQb/k42+81NuxUo3DFNH oflFtSWhG8Qv3zG//R02EkE2tog99mJUJQ2Tu5PISk2KGdwpYkr+rkDDkaAj7dyPOfcy 374fvD0Vc0vUPtCoCWf5FoVUVL4DWUShYdzhMlaFyJqYYKOaIxY6b1hN/eE1qOP2m/FZ WApoPWfeTot+QZg5BN2UTcoYTxy/sB6EaRtHlu8ZigvARmgmXa8GZimnpgVp7FnelMzJ FgMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qSha4Hyp; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-134537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134537-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r27-20020a170906365b00b00a46f3e5367dsi2849937ejb.586.2024.04.07.12.33.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 12:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=qSha4Hyp; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-134537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134537-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 523651F218D9 for ; Sun, 7 Apr 2024 15:33:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0B553A1CA; Sun, 7 Apr 2024 15:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qSha4Hyp" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43ED18485; Sun, 7 Apr 2024 15:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712503983; cv=none; b=K7Av1UtgiCl9J2vrO7vLEdv09e23+GH+QbHd5076O5gD67PUs5d6DiqJUJ9BEISAVyOjhqwfD87uM0Mlh2qV1VL4Fo9ldmJ0A7qBtjU/wpMcgN3pYDwH5fLdIamsXqpcrWWHNcp9dAO+0SuV31B/2+g/aK/+pSyLIxmNLKzCd74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712503983; c=relaxed/simple; bh=AvRYUhFInEf5FxUp/Xb5Vz8WYz3KdPlt9mAh9CIAq7Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=f/XLlDcjgdwD969C0rcTSlzEWIUUA74IeYjYkt0wkMFjdfsU3SvPuMQlJTzZ8sXHKnXvtvBBjizhRT4yCKJQrrLW4wOb55hjJ1v10KcFtd19s8SgRbAI8Y48b9iL7GorfLUj5sJioCsO5HK5Y3m5dqBqZG6IPicId2U15YI4kbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=qSha4Hyp; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Sender:Reply-To:Content-ID:Content-Description; bh=MLm6iC4WNTdIn+XgL/qIwT01bSJfAFu6/aMBhdI31mM=; b=qSha4Hyp47jW+Iw55N4ejDVPWe R50J4MZBkjl1ljsl8lmbCyXXeRCtIkvr9H8+MhKWL1RqgS0YadiGyTeVkQtJaLxMBUmny++XLamZo naMhlFfBA9Wj1dQyIMiwAlars/PfCZtyAe8Qt8T38x8MmzZhs7Y1Ke7WKWdMmJ+2iKSuM9sTd8kWc ti03BmHsO/GPxs1BL3ZrhSW3dzRvZi1ubQEIkPXTCog0N0uUXnTD9dbqqZoA4UhU85Rav2dPWANty RjPUjL9YjSqCk29sHdsFWuEV0tSwNWrASf/6aoPtQvkCY0ATh+zI1NiDBPE0hrxAeAGIGnclSDIPv c5aq+uNQ==; Received: from [50.53.2.121] (helo=[192.168.254.15]) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtUVo-0000000CuIr-3hLx; Sun, 07 Apr 2024 15:32:52 +0000 Message-ID: <7a8bc242-d41e-425b-9a62-36835aca7721@infradead.org> Date: Sun, 7 Apr 2024 08:32:49 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/4] include/linux/suspend.h: Only show pm_pr_dbg messages at suspend/resume To: xiongxin , mario.limonciello@amd.com, Rafael Wysocki , hdegoede@redhat.com, linus.walleij@linaro.org Cc: Basavaraj.Natikar@amd.com, Shyam-sundar.S-k@amd.com, linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org References: <20230602073025.22884-1-mario.limonciello@amd.com> <20230602073025.22884-1-mario.limonciello@amd.com> Content-Language: en-US From: Randy Dunlap In-Reply-To: <20230602073025.22884-1-mario.limonciello@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/7/24 5:49 AM, xiongxin wrote: > From: Mario Limonciello > > All uses in the kernel are currently already oriented around > suspend/resume. As some other parts of the kernel may also use these > messages in functions that could also be used outside of > suspend/resume, only enable in suspend/resume path. > > Signed-off-by: Mario Limonciello > --- > v3->v4: > * add back do/while as it wasn't pointless. It fixes a warning. > --- > include/linux/suspend.h | 8 +++++--- > kernel/power/main.c | 6 ++++++ > 2 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/include/linux/suspend.h b/include/linux/suspend.h > index 1a0426e6761c..74f406c53ac0 100644 > --- a/include/linux/suspend.h > +++ b/include/linux/suspend.h > @@ -555,6 +555,7 @@ static inline void unlock_system_sleep(unsigned int flags) {} > #ifdef CONFIG_PM_SLEEP_DEBUG > extern bool pm_print_times_enabled; > extern bool pm_debug_messages_on; > +extern bool pm_debug_messages_should_print(void); > static inline int pm_dyn_debug_messages_on(void) > { > #ifdef CONFIG_DYNAMIC_DEBUG > @@ -568,14 +569,14 @@ static inline int pm_dyn_debug_messages_on(void) > #endif > #define __pm_pr_dbg(fmt, ...) \ > do { \ > - if (pm_debug_messages_on) \ > + if (pm_debug_messages_should_print()) \ > printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ > else if (pm_dyn_debug_messages_on()) \ > pr_debug(fmt, ##__VA_ARGS__); \ > } while (0) > #define __pm_deferred_pr_dbg(fmt, ...) \ > do { \ > - if (pm_debug_messages_on) \ > + if (pm_debug_messages_should_print()) \ > printk_deferred(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \ > } while (0) > #else > @@ -593,7 +594,8 @@ static inline int pm_dyn_debug_messages_on(void) > /** > * pm_pr_dbg - print pm sleep debug messages > * > - * If pm_debug_messages_on is enabled, print message. > + * If pm_debug_messages_on is enabled and the system is entering/leaving > + * suspend, print message. > * If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is enabled, > * print message only from instances explicitly enabled on dynamic debug's > * control. > diff --git a/kernel/power/main.c b/kernel/power/main.c > index 3113ec2f1db4..daa535012e51 100644 > --- a/kernel/power/main.c > +++ b/kernel/power/main.c > @@ -556,6 +556,12 @@ power_attr_ro(pm_wakeup_irq); > > bool pm_debug_messages_on __read_mostly; > > +bool pm_debug_messages_should_print(void) > +{ > + return pm_debug_messages_on && pm_suspend_target_state != PM_SUSPEND_ON; > >> hibernate processes also mostly use the pm_pr_dbg() function, which >> results in hibernate processes only being able to output such logs >> through dynamic debug, which is unfriendly to kernels without >> CONFIG_DYNAMIC_DEBUG configuration. This part of the patch doesn't look so good. ^^^^^^^^^^^^^^^^^^^^ > > +} > +EXPORT_SYMBOL_GPL(pm_debug_messages_should_print); > + > static ssize_t pm_debug_messages_show(struct kobject *kobj, > struct kobj_attribute *attr, char *buf) > { > -- #Randy