From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94B0BC54E8B for ; Tue, 12 May 2020 08:47:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73AFE2072B for ; Tue, 12 May 2020 08:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729226AbgELIrY (ORCPT ); Tue, 12 May 2020 04:47:24 -0400 Received: from foss.arm.com ([217.140.110.172]:49504 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgELIrY (ORCPT ); Tue, 12 May 2020 04:47:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B14F21FB; Tue, 12 May 2020 01:47:23 -0700 (PDT) Received: from [10.37.12.83] (unknown [10.37.12.83]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A066F3F305; Tue, 12 May 2020 01:47:21 -0700 (PDT) Subject: Re: [PATCH] memory/samsung: reduce unnecessary mutex lock area To: Krzysztof Kozlowski , Bernard Zhao Cc: 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 References: <20200508131338.32956-1-bernard@vivo.com> <20200512065023.GA10741@kozik-lap> From: Lukasz Luba Message-ID: Date: Tue, 12 May 2020 09:47:19 +0100 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: <20200512065023.GA10741@kozik-lap> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. This patch should not be taken IMO. Maybe we can release lock before the if statement, just to speed-up. Regards, Lukasz > > Best regards, > Krzysztof > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEAD1C54E4B for ; Tue, 12 May 2020 08:47:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B97D4206CC for ; Tue, 12 May 2020 08:47:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tanj0L8V" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B97D4206CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xIm2ayWkeF2kLLxko8wKBeEsu8nUYpSjTFb4iMSAkTU=; b=tanj0L8VW9+MqFQJvzrr19d+H I+7FbeTIg191DT3OQZI+ugj3sVcbycsh0CoIkSAG1rwXkb6RWYtV9cn6n5suHCDb9Y+Ag+XQgwxvr hyH49XRCBQnsrn7oJ7pfJJPgG3IrqodxUZ4YHj7zFaAsfjpank/NpvPWcaOX/94MIvIFr0WuOr77M oxFlDZfwfIE5Sh8TQR/aTpmjNT/lQuIvausFCvCTjx5R2AOoI1d4cX1rbbY+ArTT3t/CRO98u01Ma 19An8gFixfY8i8zsbfpPVgPVFK/Il9LyXc6f4ohffDACXEVDJ8WarP1tvuQ1xcpXdwzIuTfoMwhZe bgzr7G/DQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYQZW-0008NX-6g; Tue, 12 May 2020 08:47:30 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYQZS-0008MU-NI for linux-arm-kernel@lists.infradead.org; Tue, 12 May 2020 08:47:28 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B14F21FB; Tue, 12 May 2020 01:47:23 -0700 (PDT) Received: from [10.37.12.83] (unknown [10.37.12.83]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A066F3F305; Tue, 12 May 2020 01:47:21 -0700 (PDT) Subject: Re: [PATCH] memory/samsung: reduce unnecessary mutex lock area To: Krzysztof Kozlowski , Bernard Zhao References: <20200508131338.32956-1-bernard@vivo.com> <20200512065023.GA10741@kozik-lap> From: Lukasz Luba Message-ID: Date: Tue, 12 May 2020 09:47:19 +0100 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: <20200512065023.GA10741@kozik-lap> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200512_014726_808106_B3ED87A0 X-CRM114-Status: GOOD ( 17.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: opensource.kernel@vivo.com, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Kukjin Kim , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. This patch should not be taken IMO. Maybe we can release lock before the if statement, just to speed-up. Regards, Lukasz > > Best regards, > Krzysztof > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel