Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2216011imm; Thu, 7 Jun 2018 07:12:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKYDEvGRkCG2PQ7j0jhm3yMqnAjJkZinVX/m72SXkLmD3Ajb52N4Vp9kcvywGrVzRJ+FaWB X-Received: by 2002:a62:8f8c:: with SMTP id n134-v6mr2002618pfd.66.1528380754119; Thu, 07 Jun 2018 07:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528380754; cv=none; d=google.com; s=arc-20160816; b=qlStVgpSCmw1/zjKc/A1yA+wiytnyXLyjYCvzIdM5Am1Qkb/g15KjdYOP0VYckz4Z7 vUXvIZhZWoufgBHpSBdeazvBWmont0/+X/kav3lKQCrZzSl4l7MAByWxNC4fcwxZ8xdz qbI0B5u4DqCrJqvHZv7+ZWm1Cp53niYI2Eo4MbLusgu/7N6TiLTIfRdoou1Rb6hmoAmB iTwEVAwnBx+01xFL1qyzJjTqvEY9efjGQZUddQoxNq9kq3sfkUDM/f3VFcZn+7uHZeMz 8PR0KZw4605PT/hHleIl3uZMVRX5ICVJeN5fDPKCldktFXkI44SVkAYykhbJIY47EgJ6 EkxA== 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:dkim-signature :arc-authentication-results; bh=o1Q48xep+oSfSgwhPdpkG4OeimmgXTnAy1K9s3bqo1w=; b=eVYb9L/CST2Vqy+FunewKKN3n0P3K8BbWoMFhMHgOQT7hbtQQsKeoARqO8tELj9niN QSG5XSwZzdCNuF116vVnj7TEVofTXKqh/RZJp7dZe3vqIU1CBnyxst+mXN4ZubvBgLmN JHoZnOsfMk+NKIOuEXurTrukNYXVrppx5wZbr/I2xuJ3lu75dpQABZap5E73tG+ITciV FwAh4BokM+uh1RPJdlcVllXS3ZsPJaM0b9S1P+n8bpt7CUGr+5TETtNTskry8uqcUC23 bsGjIecONKLsQPHn5yzfxvS1uvvLNqsKXohdUGdlYJkgFoPfYxxBgchlR+WxgQ7qefbN d3yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kT37NPXl; 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 s14-v6si53133978plp.589.2018.06.07.07.12.18; Thu, 07 Jun 2018 07:12:34 -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=kT37NPXl; 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 S1753690AbeFGOLG (ORCPT + 99 others); Thu, 7 Jun 2018 10:11:06 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40835 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753088AbeFGOLE (ORCPT ); Thu, 7 Jun 2018 10:11:04 -0400 Received: by mail-wm0-f66.google.com with SMTP id n5-v6so19476898wmc.5 for ; Thu, 07 Jun 2018 07:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=o1Q48xep+oSfSgwhPdpkG4OeimmgXTnAy1K9s3bqo1w=; b=kT37NPXlh43+uj0oiW837j2ZU/IGWPqNeQEKDuI2BmC/PpNHQzVxlpSEvraL3FJgVc QwCIxzGwt2nA0ahezcguIx0YeKXHD7EiQU8UnewS8YZUv5yEfAknbcHHOlqM8Ay2B4nx 0Zk0OD3R3rdEb+Njlk36fKG8eaUYcCEk9IB4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=o1Q48xep+oSfSgwhPdpkG4OeimmgXTnAy1K9s3bqo1w=; b=ImkMKYXBxSvrXobuopH6LCF8Q/i3UtigTPUj0S62n0wPrWZTSAVGeOj+RMF4RHK9Om HZF2PDwEbOAzvMYxFMlCxbK5KAFfETi/g6QGFuBGCAtrgLpYY4z1aB5h8wL/CUlo/C90 O/hoHsH2Z8w1d+j3TDJQCjXugI/MBgVG+dUDTaXOFmHu1eTbiGObpVlKEVBEMmAK4fpe yUEmmD0RBSSAq5aYb41RQM85mLYugLvxcelRiWU0fQXNLcjAhOUc21npWPbb0lHiZk4B 5r/yvtLm99bLzkdAOThl9w0OpfaiiGetp7ZGz8J314j+qJgCmG6vPZ77vsNZVIIZn1+T zYEw== X-Gm-Message-State: APt69E0ch+PJHWqks7Xff/j86Dd9y4XjsdlcxjBzxyC8kX3QXXSBt03M aEXWaMsKhfodsoT/OyGw2htotQ== X-Received: by 2002:a1c:448b:: with SMTP id r133-v6mr1659123wma.55.1528380663275; Thu, 07 Jun 2018 07:11:03 -0700 (PDT) Received: from [192.168.1.75] (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.googlemail.com with ESMTPSA id g75-v6sm2843578wmd.15.2018.06.07.07.11.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 07:11:02 -0700 (PDT) Subject: Re: [PATCH V5] powercap/drivers/idle_injection: Add an idle injection framework To: Viresh Kumar 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" 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> <20180606104528.nhwcd2qnxeouk6il@vireshk-i7> From: Daniel Lezcano Message-ID: <1d542490-fcb5-33fd-ab3b-eddf3d300bd4@linaro.org> Date: Thu, 7 Jun 2018 16:11:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180606104528.nhwcd2qnxeouk6il@vireshk-i7> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/06/2018 12:45, Viresh Kumar wrote: > 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 :) We won't be able to call completion() in this case. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog