Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3427885ybb; Mon, 13 Apr 2020 07:54:55 -0700 (PDT) X-Google-Smtp-Source: APiQypJ5CGF2NMz2lSgMaO7HYS1caK8IaFQobOz+FTrXpfuFX4k1UGvq72s4KZtgjPzeGkDk1p8y X-Received: by 2002:a50:fa0b:: with SMTP id b11mr16163705edq.251.1586789695081; Mon, 13 Apr 2020 07:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586789695; cv=none; d=google.com; s=arc-20160816; b=IEbyd5Cqkuso6JK1z4ftGIEhKlo5pisDFicswJ6DTIY2VPg3qotSbfS6Zn0lmjtrrK SQv4uEgfi0lP5ocbuYPsiLsLTukhqeIaVTte3nSGlmEFjAl5OVpXg69m2koQ3pq/Y6mm hS4hQGdihBIZFFEiwvEs8leX6kIV6NkkoWgL+e1SEffDYbbA51uwLPJU3HEFZraIMqwm vsKvEsmFF78mtAYfqyUzbI+bSHylHGD+257npbDqgMb5GfZ8rSyx7O8WK0tQ1r/GfQhQ XusUxkuZcL33udCIp23XlagStNJJKxfSuempC3tXPDlGrTd88yw/dbIPGavqfyExfyI+ NHqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=sm196NiMqA8gyR8DT4vdRI+KvcOo8ha9TmgFSKUPb3I=; b=s1rSSz12IBeiz8z3hup/eouIiuwx/UXzxlogUMyWWM0j3d8f7Q7xDFgiKnZSIPKzxF Q0PxwhSlhgvI4q7ftX2rokzJ47CAN8ZKORci6V8x1CjLMs/O/TohWqsQDmE4w47TP1dw dKYMyF94/FAN+FEQL+ckqTI1SIujQ0XhNoc1sqsN591Tzm9AZeCVMJfKiL60GIdQtRuA TGqxTjATU4s/nADYrXwzZ6MMx2tAXADOTqKV3xIa2KC5pf12Qjs0B0I1d1SbuVMaQWHG nHPYbtSvS29k51qXs7qJCtH6BgJEvYLUvKtDff9hY5JJjJGa71e9/GLXP5s/njrF9P1p fTFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=SagSxSkl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si6563165ejj.432.2020.04.13.07.54.30; Mon, 13 Apr 2020 07:54:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=SagSxSkl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729450AbgDMMTg (ORCPT + 99 others); Mon, 13 Apr 2020 08:19:36 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:15646 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728344AbgDMMTd (ORCPT ); Mon, 13 Apr 2020 08:19:33 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 13 Apr 2020 05:17:44 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 13 Apr 2020 05:19:32 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 13 Apr 2020 05:19:32 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 13 Apr 2020 12:19:32 +0000 Received: from [10.24.37.103] (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 13 Apr 2020 12:19:28 +0000 Subject: Re: [TEGRA194_CPUFREQ Patch 2/3] cpufreq: Add Tegra194 cpufreq driver To: Viresh Kumar CC: , , , , , , , , , , , References: <1575394348-17649-1-git-send-email-sumitg@nvidia.com> <1575394348-17649-2-git-send-email-sumitg@nvidia.com> <20200326115023.xy3n5bl7uetuw7mx@vireshk-i7> <20200406025549.qfwzlk3745y3r274@vireshk-i7> <3ab4136c-8cca-c2f9-d286-b82dac23e720@nvidia.com> <20200408055301.jhvu5bc2luu3b5qr@vireshk-i7> <08307e54-0e14-14a3-7d6a-d59e1e04a683@nvidia.com> <20200409074415.twpzu2n4frqlde7b@vireshk-i7> <00390070-38a1-19aa-ca59-42c4658bee7e@nvidia.com> <20200413062141.a6hmwipexhv3sctq@vireshk-i7> From: Sumit Gupta Message-ID: <64b609f1-efb1-425f-a91a-27a492bd3ec4@nvidia.com> Date: Mon, 13 Apr 2020 17:50:00 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200413062141.a6hmwipexhv3sctq@vireshk-i7> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To DRHQMAIL107.nvidia.com (10.27.9.16) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1586780264; bh=sm196NiMqA8gyR8DT4vdRI+KvcOo8ha9TmgFSKUPb3I=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=SagSxSkltbuOB5/r68bXwwj2Py22FS0okY336BB5sSpzMGJd+D4SfPeDrbLizmuLi FL3tnoxu3StWADbYI1GhBsP9wJIoxZ94WO+1lfqHNV6qQjHaYITR8Dng3YGYwpsdqB CBgUXEv4fhMD+z8G7TsKXaGLnByZEWvjK4ygbim5H44rSzc2FCxRfvtpLLbz/8dYbD m8LYWPG47mTzvFPYr5EEYsjlfHTCod5MqtPdKHqrdXpPlVFyl+9IjxuoH0Lv/nnAht +ETx8yIwVHTH/LBs+15idwsSoSdYWZI4aixVx24qtttaWYIpxtGYZzsPt2VQtUHD+t gux1X9yQKzipA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/04/20 11:51 AM, Viresh Kumar wrote: > External email: Use caution opening links or attachments > > > On 09-04-20, 16:51, Sumit Gupta wrote: >> We are using "read_counters_work" as local variable. So every invocation the >> function will have its own copy of counters for corresponding cpu. That's >> why are doing INIT_WORK_ONSTACK here. > > Why? To support parallel calls to reading the freq ? > Yes. >>>>>>>>>> + queue_work_on(cpu, read_counters_wq, &read_counters_work.work); >>>>>>>>>> + flush_work(&read_counters_work.work); >>>>>>>>> >>>>>>>>> Why can't this be done in current context ? >>>>>>>>> >>>>>>>> We used work queue instead of smp_call_function_single() to have long delay. >>>>>>> >>>>>>> Please explain completely, you have raised more questions than you >>>>>>> answered :) >>>>>>> >>>>>>> Why do you want to have long delays ? >>>>>>> >>>>>> Long delay value is used to have the observation window long enough for >>>>>> correctly reconstructing the CPU frequency considering noise. >>>>>> In next patch version, changed delay value to 500us which in our tests is >>>>>> considered reliable. >>>>> >>>>> I understand that you need to put a udelay() while reading the freq from >>>>> hardware, that is fine, but why do you need a workqueue for that? Why can't you >>>>> just read the values directly from the same context ? >>>>> >>>> The register to read frequency is per core and not accessible to other >>>> cores. So, we have to execute the function remotely as the target core to >>>> read frequency might be different from current. >>>> The functions for that are smp_call_function_single or queue_work_on. >>>> We used queue_work_on() to avoid long delay inside ipi interrupt context >>>> with interrupts disabled. >>> >>> Okay, I understand this now, finally :) >>> >>> But if the interrupts are disabled during some call, won't workqueues face the >>> same problem ? >>> >> Yes, we are trying to minimize the case. > > But how do you know workqueues will perform better than > smp_call_function_single() ? Just asking for clarity on this as normally > everyone tries to do smp_call_function_single(). > This was done considering long delay value as explained previously. Do you think that smp_call_function_single() would be better than work queue here? > -- > viresh >