Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6845670rwp; Tue, 18 Jul 2023 06:44:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGnlyLIfDttFQx8mqLtTtj7WD3GHcRXgqD+HYQlGlspQcsKBGgJ359K77ILwI76VlmjZ7as X-Received: by 2002:a05:6a21:329a:b0:134:4de4:d5e6 with SMTP id yt26-20020a056a21329a00b001344de4d5e6mr10917665pzb.57.1689687858169; Tue, 18 Jul 2023 06:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689687858; cv=none; d=google.com; s=arc-20160816; b=TYqTOWAgvEgZrIbkCBMFZBDN3eP9y/k1uLMRt3PhAFOD12ZRU57Y9GZdTRp3KMQBvC sNPMiyYg5PQjJbllKPnyMeYcGWN3OFpwvNN8+WAsqZO8+klYjwGi52hYqayOH7Tf/dU5 LuxCiG7Ib+flY8oG9vLKeygcSc7KSFkGrfjCf94lpihSvlouc6SfA491iI233L/Vwna4 ia6o/VMttcs1qtGb7Z8gs6VhJvm8TyztkWobamBxHaQSP75pVhxpy72V7HDyuHXqdKa3 nTXrfs11UgpUdfqxsnKoaUALSKV2plLnwjGl0xpAymaBpNFSvkqa8a/7IlqzPbeG87v9 2BFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=iww2YEbYdi8iqKEDlCZLBSWbeP4j7TWfCGa+vagGLWY=; fh=JE8jcatdImuDCryrSpP6y1+uRf6YylGl+a3Fqw83t+4=; b=YHLucDNhiDk4F1nnaQA1jbednUGa3o5a2fHw07sd/cbb0hngw/U8toKTfqH4WBBmTE 26VfHvVwqL+NtdqSr8BDt3NFlsVjv/UBJ0SNcWCEn1cB9hE2b3sVFi5aME7N+VCoG7J+ FpjPQlBh5KA55gcgqeoB1/s62r1qi8py3FXmlwOYH4hKSPttgorC2Hv9EOazsXIgDpWo 2fi22ZmxwfwTj4gLBPNHUuK/hDYcOEzn2zLy8uLx0cCt2qif1E90GMsAaUiP6cYfXtV3 Cpzc5L0vWaLUpOWSqU3WFJPlL7GjFVWWdgmr3irxSQXc0OHzIumgN/Ug3OI+IyxTtgFc ScgQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e26-20020a630f1a000000b0055b0dcca8b8si1562860pgl.612.2023.07.18.06.44.05; Tue, 18 Jul 2023 06:44:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232654AbjGRNUw (ORCPT + 99 others); Tue, 18 Jul 2023 09:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232304AbjGRNUo (ORCPT ); Tue, 18 Jul 2023 09:20:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5BA83E3; Tue, 18 Jul 2023 06:20:33 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 434D22F4; Tue, 18 Jul 2023 06:21:16 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6C86E3F6C4; Tue, 18 Jul 2023 06:20:31 -0700 (PDT) Date: Tue, 18 Jul 2023 14:20:28 +0100 From: Sudeep Holla To: Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, lukasz.luba@arm.com, "Rafael J . Wysocki" Subject: Re: [PATCH v2] powercap: arm_scmi: Remove recursion while parsing zones Message-ID: <20230718132028.wtycky4amu35xxcy@bogus> References: <20230718101726.1864761-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230718101726.1864761-1-cristian.marussi@arm.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Tue, Jul 18, 2023 at 11:17:26AM +0100, Cristian Marussi wrote: > Powercap zones can be defined as arranged in a hierarchy of trees and when > registering a zone with powercap_register_zone(), the kernel powercap > subsystem expects this to happen starting from the root zones down to the > leaves; on the other side, de-registration by powercap_deregister_zone() > must begin from the leaf zones. > > Available SCMI powercap zones are retrieved dynamically from the platform > at probe time and, while any defined hierarchy between the zones is > described properly in the zones descriptor, the platform returns the > availables zones with no particular well-defined order: as a consequence, > the trees possibly composing the hierarchy of zones have to be somehow > walked properly to register the retrieved zones from the root. > > Currently the ARM SCMI Powercap driver walks the zones using a recursive > algorithm; this approach, even though correct and tested can lead to kernel > stack overflow when processing a returned hierarchy of zones composed by > particularly high trees. > > Avoid possible kernel stack overflow by substituting the recursive approach > with an iterative one supported by a dynamically allocated stack-like data > structure. > > Cc: Rafael J. Wysocki > Fixes: b55eef5226b7 ("powercap: arm_scmi: Add SCMI Powercap based driver") Makes sense, Acked-by: Sudeep Holla -- Regards, Sudeep