Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4653451ooa; Tue, 14 Aug 2018 08:46:12 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwtCdvdSo9dI+rOU1Ul325zR0z8oeqY8R5rT/kHtebCBOFjJE6RRnRZ34Ct83fuwi3I/MjB X-Received: by 2002:a17:902:9a8a:: with SMTP id w10-v6mr21031641plp.14.1534261572091; Tue, 14 Aug 2018 08:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534261572; cv=none; d=google.com; s=arc-20160816; b=uJJyPtaMn+MqFyZ30Pm+nEUYGghRwFyomhR0BefpCN+UAV2YAFipW6XBKajbuW4JZs 9XzA5t6+VczW5z7lydFcLATAJe8jhbNBFQN7WKdf/UH1NI6QZuhWsy4R0qg9PbNAMwVv QDyrH2ClYwd+QfAIepEOSfqTy5UR9mJiYDu9ApMNaTBlN+mNjltCzZGXy+h6E7FNIv5/ 1U6z0+goE7gSxpGLchsTSZzqyrPQq8JwCtJFIY7FC/lkBwDOzwsaZbrpoiuwHmUCKv9U Yrgz/0pJeTbvo7xd36yDPAwpDS7qurmE/lPFwqEKgypXcex+HIpCBoiK+vQYw02gIGuC NPCQ== 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=xDd02qhn1HlzRtPIFiqUVt7Wk6LveQRRqYNfPxEKPJ8=; b=xViCGCH9su812zxHYRdEWwXHZLmDZA4gou1SOAodHkBRp9pYeMrhKd4QIuDzKJpKuK teiCtjCXlGlsOyFvNgI49qdOReqVaReOv5/ijP3VDnGl44929pHIGbqhpmhIi9n/KhvG vTchPVUFjE08TKpYlHUYBAxDSJFdPla1aO5xKn5ARZVW/6tx6Q4kYdT572e/eL4Qwq2p 3x23/By5xdESDooBHrEzyCgIsHJv+wqmRm6wz1VvfX2/P8BY7RcyUSpO1C71+WjngKHq Cg+Uj9VfDtZKjebyo5DEygWAeBCpe14rOzatcn9f9C+BDyJKc8V+lHzwqAPCmQYILLkE 8S7g== 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 p17-v6si22612331pfd.76.2018.08.14.08.45.57; Tue, 14 Aug 2018 08:46:12 -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 S1732072AbeHNScB (ORCPT + 99 others); Tue, 14 Aug 2018 14:32:01 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45214 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbeHNScB (ORCPT ); Tue, 14 Aug 2018 14:32:01 -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 50D9B80D; Tue, 14 Aug 2018 08:44:20 -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 110663F5BD; Tue, 14 Aug 2018 08:44:16 -0700 (PDT) Subject: Re: [PATCH v3 03/14] sched/core: uclamp: add CPU's clamp groups accounting To: Patrick Bellasi , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: 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> From: Dietmar Eggemann Message-ID: Date: Tue, 14 Aug 2018 17:44:15 +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: <20180806163946.28380-4-patrick.bellasi@arm.com> 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/06/2018 06:39 PM, Patrick Bellasi wrote: [...] > +/** > + * uclamp_cpu_put_id(): decrease reference count for a clamp group on a CPU > + * @p: the task being dequeued from a CPU > + * @cpu: the CPU from where the clamp group has to be released > + * @clamp_id: the utilization clamp (e.g. min or max utilization) to release > + * > + * When a task is dequeued from a CPU's RQ, the CPU's clamp group reference > + * counted by the task is decreased. > + * If this was the last task defining the current max clamp group, then the > + * CPU clamping is updated to find the new max for the specified clamp > + * index. > + */ > +static inline void uclamp_cpu_put_id(struct task_struct *p, > + struct rq *rq, int clamp_id) > +{ > + struct uclamp_group *uc_grp; > + struct uclamp_cpu *uc_cpu; > + unsigned int clamp_value; > + int group_id; > + > + /* No task specific clamp values: nothing to do */ > + group_id = p->uclamp[clamp_id].group_id; > + if (group_id == UCLAMP_NOT_VALID) > + return; > + > + /* Decrement the task's reference counted group index */ > + uc_grp = &rq->uclamp.group[clamp_id][0]; > +#ifdef SCHED_DEBUG > + if (unlikely(uc_grp[group_id].tasks == 0)) { > + WARN(1, "invalid CPU[%d] clamp group [%d:%d] refcount\n", > + cpu_of(rq), clamp_id, group_id); > + uc_grp[group_id].tasks = 1; > + } > +#endif This one indicates that there are some holes in your ref-counting. 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? > + uc_grp[group_id].tasks -= 1; > + > + /* If this is not the last task, no updates are required */ > + if (uc_grp[group_id].tasks > 0) > + return; > + > + /* > + * Update the CPU only if this was the last task of the group > + * defining the current clamp value. > + */ > + uc_cpu = &rq->uclamp; > + clamp_value = uc_grp[group_id].value; > + if (clamp_value >= uc_cpu->value[clamp_id]) 'clamp_value > uc_cpu->value[clamp_id]' should indicate another inconsistency in the uclamp machinery, right? [...]