Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3647510imm; Wed, 5 Sep 2018 03:47:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYGZ66471pl/MDDYdWmtJM6RFs8DjDigUvR0too7PKY0C4vX0bpakAEe0zIgiOQK3juWrdT X-Received: by 2002:aa7:8087:: with SMTP id v7-v6mr39629415pff.38.1536144442272; Wed, 05 Sep 2018 03:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536144442; cv=none; d=google.com; s=arc-20160816; b=xYQRjAomtiHNrTzFoR1HnvWvuQaueM4t6aXgMcQGuXZJBOgLV8t8utOddMlk7eKQ98 hX+fhU3QS/TKXsKeBDo8rSMbIKFFFVYOe/aJKv+k+I33WXV1SUUQrKIcjGYluNuyvpPB gKDwtY9MX1ND1cVAjjZul0fwDwkx8QS0QvgjI/BrFanNB/WeKQhu2L38n2WJw0OW2omr x2TXeceaKNeh3xy/UWe1XdmvQ+btqFytfz6FZgnJtHZAl2xQ2ebfJxAeJCkNBzSXNZNt XrPpsGHWRDFu/vuQIgyBMQl+Ptw0gvNZOY8HR1YQvB3Ibvv8WuntfLa/odsh+Uy6zCbs V+gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tOd4GvYrnhdUj6fEO4RnJiJRvggt3OirbLP9E2UErwc=; b=o75z5hsPJexX2C6RMoMlk/J9SW9o0bWnPProLsnqd6yztRaBRO2z1LK+rDAU2OEhCj YEDorJT1E05V4ayT10RItuNeyghKdo/ozv7y9Fg/6T1pLXhU1eBZTm16HeQxW6AurelI yv53lN+bX9nUsLX5k6fdOqRnesBo7fttZ22gcte4q/hlJCmKUssr/+ZPBORXoNuJn0Q5 Yye8ih4Q+cHIjtfRvrxi88g8doaaRIdEU9JCGUkLCJRqCkpvLH70FBHLHZRCTuMERbQz IKxrEEoWExCP9s/6V+aGJYdQEyhMYjGve4SGVwJ2d5QkEpTjYAR9pe7opiazL1/ZCjs7 /x2A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1-v6si1599223plr.455.2018.09.05.03.47.06; Wed, 05 Sep 2018 03:47:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727645AbeIEPPb (ORCPT + 99 others); Wed, 5 Sep 2018 11:15:31 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53183 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726071AbeIEPPb (ORCPT ); Wed, 5 Sep 2018 11:15:31 -0400 Received: by mail-wm0-f66.google.com with SMTP id y139-v6so7408717wmc.2 for ; Wed, 05 Sep 2018 03:45:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tOd4GvYrnhdUj6fEO4RnJiJRvggt3OirbLP9E2UErwc=; b=OcD2wDAVZzX6JQHy3P0++bl7AO+jMF9OzA+nt254YiQaFoMQx8PcMsL/33DUQEqD2Q Drt7jG9EgDC4jg+CPWggEssoj00IXBT6cyU91V0ChAT7KKos6mHSCnz6vGgTPGA0tBhf 2p9Y45oeoHg8KPvRQFvL4MoXAADXdnvbTCjVi1rKFnPh7Z0ROk0Yc8gaAIIQj1rSmJRC x6H1HHizmBDp/AbXSm1kaqzh7JmAu0NDnWQiSKfDiNkoqfTQxX8T8YJIpR3yfncn31N7 nN+4Clc+yoQgliirkw6xVZDddQa1ovwIQZfI/Qr7qzdoS49zxagnZsZAOmyNjXfvLZli c71g== X-Gm-Message-State: APzg51AzE1Ydaons78xwZhkUWsl4t3x1+CdA95turKnrXywa4g8vFWzW /QhykNMa9kowo6KpHOwdgRM16Q== X-Received: by 2002:a1c:3906:: with SMTP id g6-v6mr9157wma.50.1536144350492; Wed, 05 Sep 2018 03:45:50 -0700 (PDT) Received: from localhost.localdomain ([151.15.227.30]) by smtp.gmail.com with ESMTPSA id 127-v6sm1635959wmb.30.2018.09.05.03.45.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Sep 2018 03:45:48 -0700 (PDT) Date: Wed, 5 Sep 2018 12:45:45 +0200 From: Juri Lelli 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 , Quentin Perret , Dietmar Eggemann , Morten Rasmussen , Todd Kjos , Joel Fernandes , Steve Muckle , Suren Baghdasaryan Subject: Re: [PATCH v4 02/16] sched/core: uclamp: map TASK's clamp values into CPU's clamp groups Message-ID: <20180905104545.GB20267@localhost.localdomain> References: <20180828135324.21976-1-patrick.bellasi@arm.com> <20180828135324.21976-3-patrick.bellasi@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180828135324.21976-3-patrick.bellasi@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 28/08/18 14:53, Patrick Bellasi wrote: [...] > static inline int __setscheduler_uclamp(struct task_struct *p, > const struct sched_attr *attr) > { > - if (attr->sched_util_min > attr->sched_util_max) > - return -EINVAL; > - if (attr->sched_util_max > SCHED_CAPACITY_SCALE) > - return -EINVAL; > + int group_id[UCLAMP_CNT] = { UCLAMP_NOT_VALID }; > + int lower_bound, upper_bound; > + struct uclamp_se *uc_se; > + int result = 0; > > - p->uclamp[UCLAMP_MIN] = attr->sched_util_min; > - p->uclamp[UCLAMP_MAX] = attr->sched_util_max; > + mutex_lock(&uclamp_mutex); This is going to get called from an rcu_read_lock() section, which is a no-go for using mutexes: sys_sched_setattr -> rcu_read_lock() ... sched_setattr() -> __sched_setscheduler() -> ... __setscheduler_uclamp() -> ... mutex_lock() Guess you could fix the issue by getting the task struct after find_ process_by_pid() in sys_sched_attr() and then calling sched_setattr() after rcu_read_lock() (putting the task struct at the end). Peter actually suggested this mod to solve a different issue. Best, - Juri