Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21647808rwd; Thu, 29 Jun 2023 20:18:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlFfXfqxKI6Tpx3OadvDY9vFPyPOl4juWwL0NUmmrr17gN8RMAvyGjLpVyt8EYGCeTc5hYsi X-Received: by 2002:a05:6a00:2d1d:b0:680:98c:c595 with SMTP id fa29-20020a056a002d1d00b00680098cc595mr2277520pfb.13.1688095125310; Thu, 29 Jun 2023 20:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688095125; cv=none; d=google.com; s=arc-20160816; b=06SjlzDS267cRIKbJ/X10iHbvYyZRHec7GRSFZDYVeaxpDqDLRyu6zqtEXQ9zmroR8 0eIMLGT1pb95E7NiuxshmXt+xwktg4RH6+Xo6svswyBM5msmt9LJMwk0xscBJdI3fc60 W1fJ56OXM6CvjMElRRdPYyLLvnwpFN+gtNPE8LIMlX4A5yoYHK+W1x1a1Rz+e4PS82pi Q/L8c5FA9T1sv9P1gYRnof+8lrlAG9AypY0pLB2Czl7t+wrXUkSo72j1FdNpul2tHCIJ glTaRPEhWsgaQq3AltqXwi5YCmJdh2TJ4DqOVulfPtpwTwj8pe9J4tu5LR98st7Kt9+p NVqw== 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:date:subject:cc:to:from :dkim-signature; bh=6hzvSD9GFhy/jKWa6fSxQTV3jRMi0i1mWv1yFuJ1OnQ=; fh=98Z1KMHclbkcRXZ/Rt0/aF3v9CvqadFC//981dwj5e4=; b=axmD+aFgmrSkwDZFZQ4tyMdFAy7uJwW5zAax+UazPCA9q4UQHZM8Oa8TIg1sOIULMe KSETY8ZBf/OeoMmVfAHEA7rySOy+c3t5elo/2rNrJtFwibvXvTZrzeg/52DV6vkj/A5l H5bNtP7zBIe9Kr8rzzb1jQhUJO63xvfrdydCN731aydnPd41WMEv9ASYf6VfBSU/EWLZ MAQO5nQjWPNMPToS54FZ5voboqVnhuIrBfYZ5HHbXkCAYbVeLiVWCkD+26DgoagLR0pK jGgnSmzv0JSVOfJYvaYX+s8abTIbTx2wQ3gkNGOJoOUTSQ4crnwlh1cAnLlcfFr5ELU2 Ozvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=YSpovZIT; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn15-20020a056a00340f00b0067bc790ce11si6551668pfb.161.2023.06.29.20.18.30; Thu, 29 Jun 2023 20:18:45 -0700 (PDT) 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=@bytedance.com header.s=google header.b=YSpovZIT; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231831AbjF3Cq3 (ORCPT + 99 others); Thu, 29 Jun 2023 22:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjF3Cq0 (ORCPT ); Thu, 29 Jun 2023 22:46:26 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1652E3583 for ; Thu, 29 Jun 2023 19:45:59 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id 98e67ed59e1d1-262e3c597b9so986823a91.0 for ; Thu, 29 Jun 2023 19:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1688093158; x=1690685158; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6hzvSD9GFhy/jKWa6fSxQTV3jRMi0i1mWv1yFuJ1OnQ=; b=YSpovZITc5f/rxtk6imAJ3XXDu0nxGqwQrM9vx9Pd7yO9XsCXifUh5a4AqpcOY0Um2 WgFjsoGqV+U3JIaFz/bYoWyZXb5Qa9iwb43baFMNu5bkSeUAJcg94uSn14aCncybFATs OyVJR3SiB2JXrP8E1v7mg6yCV0rb3yJ6v2/Vvc1+zR2KqbDj/CyKF/FbdHHklKzRIdPy +3b7aAu169odsbTcGNjf128+voyIc3cJB1HaNu6irgey9lpxxSJAcgKLDTqq7cDmqWn/ GQ+ev5H8/56w9z16YcUNiFue2+w2CSAZ/VWaOl4qtinnfr6WXeLlfV6tS9QG26/HkcI9 FTvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688093158; x=1690685158; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6hzvSD9GFhy/jKWa6fSxQTV3jRMi0i1mWv1yFuJ1OnQ=; b=Jup+fvwWIAZuYm09OOLdXi49bSPTIt+FZ0eAUOAiO39bcMTI5+PYdUvxeLF7hZ03NZ TbSbA3PqW+bhs5LMJo06P3Rib6sJswnDBN9mo0Tzrxm+6f5oiDYU3jZ+tuVQWWrebeRh /XrjCRyXZqyY3eBQfLZPNVg9pYW2OjShr28XWlGGrgWx1kULu83sJRy/llPoL0kouaW5 I8ipXjBJ+Uj/KTb0CPxLGOqa1n629TSai3/g0mFL8oyNomoscyK0WB3F9fo/OJDIV38W ZxDIOLgSTbP/mq/VJ5BycZ2huOdUzJYQHGiAjbWm64K1iLuhcFpIxlf35og0dK/2aF0b OYwg== X-Gm-Message-State: ABy/qLZr6buhk7SJ7TK00YLN8rM7xuamduqBbUi3eGOmA4n6C8znuzin pMOymokKAc4F6Qx1THEX92n3Uw== X-Received: by 2002:a17:90a:b81:b0:262:c291:4b6c with SMTP id 1-20020a17090a0b8100b00262c2914b6cmr1129635pjr.45.1688093158565; Thu, 29 Jun 2023 19:45:58 -0700 (PDT) Received: from localhost.localdomain ([203.208.189.9]) by smtp.gmail.com with ESMTPSA id k2-20020a17090a4c8200b002609cadc56esm10549454pjh.11.2023.06.29.19.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 19:45:58 -0700 (PDT) From: lizhe.67@bytedance.com To: tglx@linutronix.de Cc: bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lizefan.x@bytedance.com, lizhe.67@bytedance.com, mingo@redhat.com, rafael@kernel.org, tony.luck@intel.com, viresh.kumar@linaro.org, x86@kernel.org, yuanzhu@bytedance.com Subject: Re: [RFC] msr: judge the return val of function rdmsrl_on_cpu() by WARN_ON Date: Fri, 30 Jun 2023 10:45:49 +0800 Message-Id: <20230630024549.76487-1-lizhe.67@bytedance.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <87r0ptzxad.ffs@tglx> References: <87r0ptzxad.ffs@tglx> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 Fri, 30 Jun 2023 at 01:03:22 +0200, tglx@linutronix.de wrote: >Li! > >On Thu, Jun 29 2023 at 15:27, lizhe.67@bytedance.com wrote: > >> There are ten places call rdmsrl_on_cpu() in the current code without >> judging the return value. This may introduce a potential bug. For example, >> inj_bank_set() may return -EINVAL, show_base_frequency() may show an error >> freq value, intel_pstate_hwp_set() may write an error value to the related >> msr register and so on. But rdmsrl_on_cpu() do rarely returns an error, so >> it seems that add a WARN_ON is enough for debugging. > >Can you please structure your changelogs as documented in: > > https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#changelog > >instead of providing a big lump of words? > >> There are ten places call rdmsrl_on_cpu() in the current code without >> judging the return value. > >Return values are not judged. They are either ignored or checked/evaluated. > >> This may introduce a potential bug. > >Sure. Anything which does not check a return value from a function might >be a bug, but you have to look at each instance whether its a bug or >not. > >> For example, inj_bank_set() may return -EINVAL, show_base_frequency() >> may show an error freq value, intel_pstate_hwp_set() may write an >> error value to the related msr register and so on. But >> rdmsrl_on_cpu() do rarely returns an error, so it seems that add a >> WARN_ON is enough for debugging. > >This is hillarious at best. > > 1) It does not matter at all whether that function returns an error rarely > or not. > > 2) Adding WARN_ON() without justification at each call site is not > enough. Neither for debugging nor for real world usage. > >You have to come up with individual patches for each callsite to add the >WARN_ON() and in each patch you have to explain why it is justified and >why there is no other solution, e.g. taking an error exit path. > >Just slapping WARN_ON()'s into the code without any deeper analysis is >worse than the current state of the code. > >If you have identified a real world problem at any of these call sites >then adding a WARN_ON() does not solve it at all. > >I'm looking forward to your profound anlysis of each of these "problems". > >Thanks, > > tglx Thanks for all your advice. I will analysis each of these "problems".