Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2549777ybk; Tue, 12 May 2020 02:08:41 -0700 (PDT) X-Google-Smtp-Source: APiQypIKPVs5wKth/EuP4MpTjV70/arf/w0bQaqGFNaCMjvWtVqRsDYxduJ4PiOpBkAMWjtwHhgN X-Received: by 2002:a50:9a04:: with SMTP id o4mr16297915edb.289.1589274521334; Tue, 12 May 2020 02:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589274521; cv=none; d=google.com; s=arc-20160816; b=rZFVuw2scGX50pPih8s9Gc6XsHDf0arl74aOtE37vvja4UwWIryE4KOTKhcx7+y9Os 1kqDG9p04auO7rB/V9Y01D83Q2VhAOz5Qkh/Dqgc8jCxYiuTYAzzVlby8rja2fl4mNl3 pQNocST+C2Pl+KExqkeCLOeRekDnK21ngWmHy6ZiHF4L6vaYjhZ70a8tgINEYp3ETWMl DpK99kVuQf5PcXEtYLxcJRKCBqGqCmPu3fG5tRCT7Tau/BEwzuwlwHMOmSSaRA/J6hlU oyY70/dSBvYCXvg/Wk5weW23OyQi0kf8JrU+2LuJ94UxvA4v0godZYYKh9Fura5TA+fQ fu3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lsdv3Vt0EvkAdR5zxSnvs6Hcr+70G9/AaVzwCDLAY9g=; b=b9rMkfeNMIEeggnWD05TNyUKEJJlD0a0RIfNJDBCNHLpUp3P4J2lqhMZSlyuQbKriU FHP/2RAE5NqDGDI5n3DADo89si2MPx4j3nglh27gVe/zjrYloEwQnkCQhfSH6scOox5p OyIRy7rDiBhdh2XG7ktiXmSCJnvoMftR3lpqUUY8dktoPhdLffDUCHfiYakAX6ysjsaY zuJoEiaUVBI/C3NHu7NCwF1X1XPjDZ8f8JHCkoOTVllSn5SkhZG1djpo1USDcKufTt/k QAoMqo82mRdn36uTxxAbilfuCUeJnBFsSYAwkp34fMwiccv8O80H2qCrUDICjWuFMwpe iyBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z5s6zPoU; spf=pass (google.com: 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si262614edq.485.2020.05.12.02.08.17; Tue, 12 May 2020 02:08:41 -0700 (PDT) Received-SPF: pass (google.com: 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=@kernel.org header.s=default header.b=z5s6zPoU; spf=pass (google.com: 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729297AbgELJFm (ORCPT + 99 others); Tue, 12 May 2020 05:05:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:33742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728085AbgELJFl (ORCPT ); Tue, 12 May 2020 05:05:41 -0400 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34093206A3; Tue, 12 May 2020 09:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589274341; bh=HS+53ZodqD34omUaUnfZGaaf3rHBhijbLO2ygOHvWBs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=z5s6zPoUUzxvR8qdd57Vjpx+i5DWghLNc9KIZ5neo+iBD64HzEyZi8RxetyQ6FgAf p/3OXO0bk3sgpbGnbI5D8i6vos1yEge44MH1NFdXwmPDlDgqUHr3Ee8bPHRUxKlnUI xMjhjGCrlwmh7TZSetaFhmkh+6r9aiDJRhJaMysw= Received: by mail-lf1-f54.google.com with SMTP id b26so9913862lfa.5; Tue, 12 May 2020 02:05:41 -0700 (PDT) X-Gm-Message-State: AOAM531fk+a+XsbFpJ7mVFpvoIyWINsggM1WQ7lyAXYxKM/IjOioNCJZ 76INQKsifcuCF7wyrpRDnGC9916Fnk5pi8R2yds= X-Received: by 2002:a19:f00b:: with SMTP id p11mr13835301lfc.210.1589274339295; Tue, 12 May 2020 02:05:39 -0700 (PDT) MIME-Version: 1.0 References: <20200508131338.32956-1-bernard@vivo.com> <20200512065023.GA10741@kozik-lap> In-Reply-To: From: Krzysztof Kozlowski Date: Tue, 12 May 2020 11:05:28 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] memory/samsung: reduce unnecessary mutex lock area To: Lukasz Luba Cc: Bernard Zhao , Kukjin Kim , linux-pm@vger.kernel.org, "linux-samsung-soc@vger.kernel.org" , linux-arm-kernel@lists.infradead.org, "linux-kernel@vger.kernel.org" , opensource.kernel@vivo.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 May 2020 at 10:47, Lukasz Luba wrote: > > Hi Krzysztof, > > I am sorry, I was a bit busy recently. > > On 5/12/20 7:50 AM, Krzysztof Kozlowski wrote: > > On Fri, May 08, 2020 at 06:13:38AM -0700, Bernard Zhao wrote: > >> Maybe dmc->df->lock is unnecessary to protect function > >> exynos5_dmc_perf_events_check(dmc). If we have to protect, > >> dmc->lock is more better and more effective. > >> Also, it seems not needed to protect "if (ret) & dev_warn" > >> branch. > >> > >> Signed-off-by: Bernard Zhao > >> --- > >> drivers/memory/samsung/exynos5422-dmc.c | 6 ++---- > >> 1 file changed, 2 insertions(+), 4 deletions(-) > > > > I checked the concurrent accesses and it looks correct. > > > > Lukasz, any review from your side? > > The lock from devfreq lock protects from a scenario when > concurrent access from devfreq framework uses internal dmc fields 'load' > and 'total' (which are set to 'busy_time', 'total_time'). > The .get_dev_status can be called at any time (even due to thermal > devfreq cooling action) and reads above fields. > That's why the calculation of the new values inside dmc is protected. I looked at this path (get_dev_status) and currently in devfreq it will be only called from update_devfreq() -> get_target_freq()... at least when looking at devfreq core and governors. On the other hand you are right that this is public function and this call scenario might change. It could be called directly from other paths sooner or later. > This patch should not be taken IMO. Maybe we can release lock before the > if statement, just to speed-up. Yep. Bernard, you can send just this part of the patch. Best regards, Krzysztof