Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp591698imm; Wed, 15 Aug 2018 02:38:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwFa63UyJ7GJZisdhBJS+xQuTUn2QJkmhEh0x9Lw8RWciWg2Nnj2jhWmfj9hrGccJUDMj0b X-Received: by 2002:a63:4d47:: with SMTP id n7-v6mr24418909pgl.270.1534325900737; Wed, 15 Aug 2018 02:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534325900; cv=none; d=google.com; s=arc-20160816; b=M0i9wB/gU0Y6HIQF0IiYqx8QAGEqRDKxfQ3StLWp/bdHcc/ab7IRep/rxZSwSUWk34 RsntHwmRQVKsettZA9Gt/QxRjxFk5HjUYhHoee3iGtCRPo0fBa9TU7UGgLE7QhLGOFzX bkjMMN7ukuCoq4RDFSJVbxlr3qHQJ9HUKSu0LOcUoUqN3pF7U8iw0kLVwxHWfNCqMZXG mumAYdt6kq3UAAw2IiVRV1SFNu98HIFDCrcU1wbai9EOwxySDvrdoN6bqKNqK8IznQnb Q/+N6Zlg/QnIhxSrFsV0q1KrisOt1/2B0UyhIxmtFsGIc2Kq93bwIayFzYA0z7QUVbQz mq2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=QHhri/NBwY8P5TYerXXgbub7KWp0l/0B5whNw3om5hw=; b=fN380TgNk3XKbxLvzMMvkgfEZOzKF0FcdViRlfTfTYZMEiAqCz3+e/De4U/oQbOtem pajpX0Skp0hpvRy3RBrXKksDqMplX+DVpcZgk0nToos3YGvuuak/yRjs7yEnKS8zVebh zMYBQ5WvZdql3LA8XawZBM+t5yqEfb+SWkWXhLD0r2FiNx6Mbcp73ScIkulq7Kq14+iM j2AFOPC2JeOorzRr9WeXp9P8oRnSbrgf/Lny4tz+VQAIGPXQnZhkHPZpyJZJ0fdK0acI 7f5pauHg1Kojoj+DecyKpb/YPI55xLWdy46z4PC1+NPoFt5TrqOEcr2Dg+lHyZk6KMoI v+nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185-v6si22835031pgj.511.2018.08.15.02.38.05; Wed, 15 Aug 2018 02:38:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729033AbeHOM2o (ORCPT + 99 others); Wed, 15 Aug 2018 08:28:44 -0400 Received: from foss.arm.com ([217.140.101.70]:53128 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728668AbeHOM2o (ORCPT ); Wed, 15 Aug 2018 08:28:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AF16718A; Wed, 15 Aug 2018 02:37:18 -0700 (PDT) Received: from [0.0.0.0] (e107985-lin.emea.arm.com [10.4.12.239]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6BDAC3F5BD; Wed, 15 Aug 2018 02:37:15 -0700 (PDT) Subject: Re: [PATCH v3 03/14] sched/core: uclamp: add CPU's clamp groups accounting To: Patrick Bellasi Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Tejun Heo , "Rafael J . Wysocki" , Viresh Kumar , Vincent Guittot , Paul Turner , Morten Rasmussen , Juri Lelli , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan References: <20180806163946.28380-1-patrick.bellasi@arm.com> <20180806163946.28380-4-patrick.bellasi@arm.com> <20180814164905.GG2605@e110439-lin> From: Dietmar Eggemann Message-ID: <7c45c1a8-24cb-6798-5b6f-3b5dfc9b490d@arm.com> Date: Wed, 15 Aug 2018 11:37:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180814164905.GG2605@e110439-lin> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/14/2018 06:49 PM, Patrick Bellasi wrote: > Hi Dietmar! > > On 14-Aug 17:44, Dietmar Eggemann wrote: >> On 08/06/2018 06:39 PM, Patrick Bellasi wrote: [...] >> This one indicates that there are some holes in your ref-counting. > > Not really, this has been added not because I've detected a refcount > issue... but because it was suggested as a possible safety check in a > previous code review comment: > > https://lore.kernel.org/lkml/20180720151156.GA31421@e110439-lin/ > >> It's probably easier to debug that there is still a task but the >> uc_grp[group_id].tasks value == 0 (A). I assume the other problem exists as >> well, i.e. last task and uc_grp[group_id].tasks > 1 (B)? >> >> You have uclamp_cpu_[get/put](_id)() in [enqueue/dequeue]_task. >> >> Patch 04/14 introduces its use in uclamp_task_update_active(). >> >> Do you know why (A) (and (B)) are happening? > > I've never saw that warning in my tests so far so, again, the warning > is there just to support testing/debugging when refcounting code > is/will be touched in the future. That's also the reason why is > SCHED_DEBUG protected. Ah, OK, I thought you really see it more often and that it also relate to Pavan's comment on 02/14 about the missing treatment of exiting tasks. If this is only for testing/debugging, I would suggest a simple one line BUG_ON() You find CONFIG_SCHED_DEBUG=y in production kernels as well. [...] > Here you right, I would say that it should always be: > > clamp_value <= uc_cpu->value[clamp_id] > > since this matches the update done at the end of uclamp_cpu_get_id(): > > if (uc_cpu->value[clamp_id] < clamp_value) > uc_cpu->value[clamp_id] = clamp_value; > > Perhaps we can add another safety check here, similar to the one > above, to have something like: > > clamp_value = uc_grp[group_id].value; > #ifdef SCHED_DEBUG > if (unlikely(clamp_value > uc_cpu->value[clamp_id])) { > WARN(1, "invalid CPU[%d] clamp group [%d:%d] value\n", > cpu_of(rq), clamp_id, group_id); > #endif > if (clamp_value == uc_cpu->value[clamp_id]) > uclamp_cpu_update(rq, clamp_id); Yes, but I would prefer a BUG_ON() one liner.