Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp642571imm; Wed, 6 Jun 2018 03:46:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKI3SvgVJqdPrEtpeFpzzrny1T3lUG47HpWazcODcuMGvMFFFngkIswHTo1Vkou0zageXje X-Received: by 2002:a62:4715:: with SMTP id u21-v6mr731734pfa.89.1528281985924; Wed, 06 Jun 2018 03:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528281985; cv=none; d=google.com; s=arc-20160816; b=SyStYlND43x2o8Mp/TrpBHglwRgbOYgFfX5+Oj1HEJh16us9GAuk3AKs3vkL1Iiolw SdRqHXYkrM/WogARYJmhQq+imJQypGury6Bs5WQJg8DkCHv7eRtPGWtg9l2qBeLi5g4P IjrsYQFb63ztk4mkpjI2L2V9Q5ssulKX63+++llOmIUfKW/NMa6O3m/3PiuYqFC2e68z SuxXjsqbniSFURzD2LxYjOns3tE/gVua7LlVcRcQfwoHhbj+AE/VRewEn3xnJ+LeRtFh hSSVqpwbyCjuPeSv+vmV3kcE3K42/lkr6neTHa8vygvTFxuo9Z7vqW1pfl3XC4GG3EnV pgVQ== 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:dkim-signature:arc-authentication-results; bh=9r4kss+MnyQv8SxaYT1nvjYObYIWMxsa81ZFwKdNBzs=; b=oHWhnDyLUtX+ZUYzD+Kw75Hc6kPs3hrx8pCOwgzyVkmCS8CvxqUwW/+kpTx2Fa7wFj jLvPzwtoNwnmhbt2WBr58waDmyOsPUKcjNtMRgwjHkFM+ee1A+pis5zusepRNR6LaCTQ hKZ49eKSs3SUkot5nA2eveZmmCfIzs2RHv0gbUG3fOxxIBtmcoXKLkm3243kQEvjkuM6 ostIKUnY4VuE4k1Ml+ATCyHzW8g53nILXuYeE8Qe8OnGDNCzQmjDHfHQTkewDJpwCuho AOxq4UrtB+xAPZ4lAM9/ldFaq6YDB8DLku9b1/d9SIWY6twg8p32WQ0NxMsh2zqn5m8x QHpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LNfau4iA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6-v6si576769pfh.137.2018.06.06.03.46.11; Wed, 06 Jun 2018 03:46:25 -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; dkim=pass header.i=@linaro.org header.s=google header.b=LNfau4iA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932615AbeFFKpd (ORCPT + 99 others); Wed, 6 Jun 2018 06:45:33 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:38195 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932589AbeFFKpb (ORCPT ); Wed, 6 Jun 2018 06:45:31 -0400 Received: by mail-pl0-f68.google.com with SMTP id b14-v6so3576452pls.5 for ; Wed, 06 Jun 2018 03:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9r4kss+MnyQv8SxaYT1nvjYObYIWMxsa81ZFwKdNBzs=; b=LNfau4iA4CgyT0+9kcgugHfX59/O/V7Gi2YTJSC63lCp703feEizV2sCgALdF3x/eP M2S7LxfQekycvaDouu54VzcxL5/bZAy9W6omP/5TIWwSk/DpuxH8gRJZRdmeVY+ONhV+ 8xYcGQmq6LP9APYtt1gW7B1PVOOr120XOpyMc= 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=9r4kss+MnyQv8SxaYT1nvjYObYIWMxsa81ZFwKdNBzs=; b=T7kFZ1Fsw/9aNdA7+NYpHI2DIub1Cn2CF0TRyBDm1xT/SFaPnCKIJnncozZnxLveOn aiZFWA6RDPOQNelanCsb/NlZa72VKt4ddVC5SpxDzQT0CNZpSXu1wPMvLv56fPeDQ8/D A0CdtHwKQKxxCM4MddNCFsfiWdf/ybIdln1sAHvFz4v+MaAUGiwlP4R3UDSFATNyqqo2 SRUp24f56gRn9C9CJxtJzO7o2NGwiWkM3JfLZ974NzmUG0grBmO9KXs5bJeR1IyZuf6Z NBIfUq/UFu5+GqFZuiylZGp2KmlRwMrJqmKau8RhVJa0LpFHHoYqVknLmC2RUQOw4Set 9/2w== X-Gm-Message-State: APt69E3N0RBj5/IYajeT6pLBd2ooGhi5qCSKQ/KgNLNiXsM++VyKejEd swWDrRHOlWD024PLlW9eGWSIJA== X-Received: by 2002:a17:902:ba87:: with SMTP id k7-v6mr2697003pls.271.1528281931258; Wed, 06 Jun 2018 03:45:31 -0700 (PDT) Received: from localhost ([122.172.63.23]) by smtp.gmail.com with ESMTPSA id g12-v6sm12475997pfh.164.2018.06.06.03.45.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 03:45:30 -0700 (PDT) Date: Wed, 6 Jun 2018 16:15:28 +0530 From: Viresh Kumar To: Daniel Lezcano Cc: rjw@rjwysocki.net, linux-kernel@vger.kernel.org, Eduardo Valentin , Javi Merino , Leo Yan , Kevin Wangtao , Vincent Guittot , Rui Zhang , Daniel Thompson , "open list:POWER MANAGEMENT CORE" Subject: Re: [PATCH V5] powercap/drivers/idle_injection: Add an idle injection framework Message-ID: <20180606104528.nhwcd2qnxeouk6il@vireshk-i7> References: <1528190208-22915-1-git-send-email-daniel.lezcano@linaro.org> <20180605103917.pyhhcobdvaivqv6g@vireshk-i7> <57d769f8-46ea-512e-8f89-a0439c9d053f@linaro.org> <20180606042708.mtwd66ecy2cnjp7a@vireshk-i7> <2bebd1bc-e1ad-6d22-ad1e-aee2cf8ba878@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2bebd1bc-e1ad-6d22-ad1e-aee2cf8ba878@linaro.org> User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06-06-18, 12:22, Daniel Lezcano wrote: > (mb() are done in the atomic operations AFAICT). AFAIU, it is required to make sure the operations are seen in a particular order on another CPU and the compiler doesn't reorganize code to optimize it. For example, in our case what if the compiler reorganizes the atomic-set operation after wakeup-process ? But maybe that wouldn't happen across function calls and we should be safe then. > What about: > > get_online_cpus(); > > nr_tasks = cpumask_weight( > cpumask_and(ii_dev->cpumask, cpu_online_mask); > > atomic_set(&ii_dev->count, nr_tasks); > > for_each_cpu_and(cpu, ii_dev->cpumask, cpu_online_mask) { > iit = per_cpu_ptr(&idle_injection_thread, cpu); > iit->should_run = 1; > wake_up_process(iit->tsk); > } > > put_online_cpus(); > ? Looks good this time. > I'm wondering if we can have a CPU hotplugged right after the > 'put_online_cpus', resulting in the 'should park' flag set and then the > thread goes in the kthread_parkme instead of jumping back the idle > injection function and decrease the count, leading up to the timer not > being set again. True. That looks like a valid problem to me as well. What about starting the hrtimer right from this routine itself, after taking into account running-time, idle-time, delay, etc ? That would get rid of the count stuff, this get_online_cpus(), etc. Even if we restart the next play-idle cycle a bit early or with some delay, sky wouldn't fall :) -- viresh