Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp542163ybi; Fri, 26 Jul 2019 14:25:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjQMjmYIc+y07xue5V26baxYqY5mbsaQNeChvu5MYO8YFN0fHEu8owIhTgypIr9MTS800Q X-Received: by 2002:a17:90a:cb01:: with SMTP id z1mr99085456pjt.93.1564176330184; Fri, 26 Jul 2019 14:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564176330; cv=none; d=google.com; s=arc-20160816; b=Pza8G1qoWOqVt+8pJ4aZU1TBuWB/wnPmPOdasJpBMhsg6BUxfxQ5h4uewF4DksJEZC JRV2x10tghiMoFTS7Hb9H8fxgCcV0acTzWYK3uXJL1iJ1TVkoq1rRbH0npqJkGwnj98l 0Wcnl57V129gZMSIp0fIs+Vu2324NeLjR+68rBzUFBQvbusJjownPw+jPR3Op0Pp5tFk oqFSHYT3GBCdXVnl2jLOjsP1LNL0Xi92Mfe7V6Wt/PtM40b1lUvu/at5o90/K+Qj6Hl1 o0A7aRrrD6//fd/aZoCDS+vN3nsBlUnT8uAq9Cqtb6oRQPdUOwfOSKLVf2bmescwuzLB HxXw== 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=owpXJzkwRhTQpFv3YFYd1YLSHkq3ebxH7N/mkMxT22w=; b=N8NZeveEco0X9/O5OoOxarYWxjMGHNN5boxf6BRZdzv4USSK0uRRNRxuLPVXzzAMrp ahTLOkO+pnslOl9MBofpvSEZPeaITky7BmZ3t0gzSIma4Rd02uC57zyvsEYttHK2B/t9 Xu5YHWs4CYMesbkZZMva2QSrI4iGx3hFAoFuR+8qKb6Z6Oh66rIXrONUAVu/xou7p4Ts 18OVTYmTX4P2uOV8zbox585fn0DYG0mdKDH4xn/4m1C+5kV4L2RZH1asCFP2Ru+mXRUd Gq9kqdio7gW/kK+H86n8sKowzh8BmhvWNJ42OYFiIa/V9o0eBsqahKZFUX+N8BFJsc+K 1MgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="aMJ/j5Za"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si18617338plt.306.2019.07.26.14.25.15; Fri, 26 Jul 2019 14:25:30 -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=@google.com header.s=20161025 header.b="aMJ/j5Za"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728514AbfGZVY2 (ORCPT + 99 others); Fri, 26 Jul 2019 17:24:28 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46641 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728454AbfGZVYT (ORCPT ); Fri, 26 Jul 2019 17:24:19 -0400 Received: by mail-qt1-f193.google.com with SMTP id h21so53977877qtn.13 for ; Fri, 26 Jul 2019 14:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=owpXJzkwRhTQpFv3YFYd1YLSHkq3ebxH7N/mkMxT22w=; b=aMJ/j5Za4QMl8Pf2M7kaOR415fQRH6rbjYvIyS/i6JoHNO1516z0Q7L7CjFPJ7OSS1 51Tf7qtTEW9o3QxpAl09Ian0zWGVtbbD0nG+Um3baSMk8x4ZwW46HfklJgWl9rFAmdxC wOIhrnvM2feyVB+D596KSvP2fwa183EZXUZsR09c5+V9awonePLsdUEd9pE+vVyhKSl4 dLsxG2Cd86+m28G2I5cieWpy294e4O+naTmRX3y3ThmoJ7iWdyCdI1EvgPueMmA5RgwT sq/HsxDn/okq7PDtBIalb+vyn7ZR4elNjex9aOv4MTGiRGn9pQe0NeSPFFZAvApATh8c GZdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=owpXJzkwRhTQpFv3YFYd1YLSHkq3ebxH7N/mkMxT22w=; b=f2Kw9wwPU6V8IHC/vDLoDl1Jk9DtwRR/LOx6qpVWYk5MmU/xzj6AcAhdVvaRf9vs9m 1E2kCtDB+gxbsB7zC7CLIVN9WjI4MSGTCsruWFHpmKDUT32yyDHqR9A5bm1ny4Any33o FrVkv20RBOHK46l83YXdgL4v5MvfCZgK3zPMgQBOnfmepGXZHDE2tbwWV/3Yk3VbhrbQ lDOWDOrk5yQuXeQf+qdnomW7F75cBW5wWV4e1B9YRAGUsCdhQEavTmTA7fOPufRxJuVm LnyLadvyvcC1RcnSVZM0BdHAY4V4r/VCPM04B0Wi0PJ4JVxGRmf7mfv6wb/onZ4Yz7yu /f6Q== X-Gm-Message-State: APjAAAWgjwZ+E9SLZr3yqs+9LsJDpV+DMr++rB1VnB+pBzCVc1AsPDFM qy2UeNoA9yU1mGkfa5VCEv4icFQ2Mob0os6lylzmWw== X-Received: by 2002:a0c:baa1:: with SMTP id x33mr70919945qvf.200.1564176258418; Fri, 26 Jul 2019 14:24:18 -0700 (PDT) MIME-Version: 1.0 References: <20190717222340.137578-1-saravanak@google.com> <20190717222340.137578-4-saravanak@google.com> <20190723102842.t2s45zzylsjuccm4@vireshk-i7> <20190725030712.lx3cjogo5r7kc262@vireshk-i7> <20190725051742.mn54pi722txkpddg@vireshk-i7> In-Reply-To: From: Saravana Kannan Date: Fri, 26 Jul 2019 14:23:41 -0700 Message-ID: Subject: Re: [PATCH v3 3/5] OPP: Improve require-opps linking To: Viresh Kumar Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Sibi Sankar , Android Kernel Team , Linux PM , LKML 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 Thu, Jul 25, 2019 at 6:52 PM Saravana Kannan wrote: > > On Wed, Jul 24, 2019 at 10:17 PM Viresh Kumar wrote: > > > > On 24-07-19, 21:09, Saravana Kannan wrote: > > > On Wed, Jul 24, 2019 at 8:07 PM Viresh Kumar wrote: > > > > We should be doing this whenever a new OPP table is created, and see > > > > if someone else was waiting for this OPP table to come alive. > > > > > > Searching the global OPP table list seems a ton more wasteful than > > > doing the lazy linking. I'd rather not do this. > > > > We can see how best to optimize that, but it will be done only once > > while a new OPP table is created and putting stress there is the right > > thing to do IMO. And doing anything like that in a place like > > opp-set-rate is the worst one. It will be a bad choice by design if > > you ask me and so I am very much against that. > > > > > > Also we > > > > must make sure that we do this linking only if the new OPP table has > > > > its own required-opps links fixed, otherwise delay further. > > > > > > This can be done. Although even without doing that, this patch is > > > making things better by not failing silently like it does today? Can I > > > do this later as a separate patch set series? > > > > I would like this to get fixed now in a proper way, there is no hurry > > for a quick fix currently. No band-aids please. > > > > > > Even then I don't want to add these checks to those places. For the > > > > opp-set-rate routine, add another flag to the OPP table which > > > > indicates if we are ready to do dvfs or not and mark it true only > > > > after the required-opps are all set. > > > > > > Honestly, this seems like extra memory and micro optimization without > > > any data to back it. > > > > Again, opp-set-rate isn't supposed to do something like this. It > > shouldn't handle initializations of things, that is broken design. > > > > > Show me data that checking all these table > > > pointers is noticeably slower than what I'm doing. What's the max > > > "required tables count" you've seen in upstream so far? > > > > Running anything extra (specially some initialization stuff) in > > opp-set-rate is wrong as per me and as a Maintainer of the OPP core it > > is my responsibility to not allow such things to happen. > > Doing operations lazily right before they are needed isn't something > new in the kernel. It's done all over the place (VFP save/restore?). > It's not worth arguing though -- so I'll agree to disagree but follow > the Maintainer's preference. > I was taking a closer look at the OPP framework code to try and do what you ask above, but it's kind of a mess. The whole "the same OPP table can be used by multiple devices without the opp-shared flag set" is effectively breaking "required-opps" at a minimum and probably a lot more cases. I don't think I can rewrite my patch the way you want it without fixing the existing bugs. Let's take this example DT (leaving out the irrelevant part): OPP table 1: required-opps = ; OPP table 2: Device A: operating-points-v2 = <&OPP table 1> Device B: operating-points-v2 = <&OPP table 2> Device C: operating-points-v2 = <&OPP table 2> Let's say device B and C add their OPP tables. They both get their own "in-memory" copy of the OPP table. They can then enabled/disable different OPP entries (rows) and not affect each other's OPP table. Which is how it's expected to work. Now if device A adds its OPP table 1, the "in-memory" required_opp_tables pointer of OPP table 1 can end up pointing to either Device A's copy of the OPP table or Device B's copy of the OPP table depending on which happens to be added first. This effectively random linking of OPP tables is mutually exclusive to the point of required-opps. Also, at a DT definition level, OPP table 1 pointing to OPP table 2 when OPP table 2 is used by more than one device doesn't make any sense. Which device/genpd is OPP table 1 saying it "requires to operate at a certain level"? So I propose that we should consider the OPP table DT configuration invalid if one OPP table points to another OPP tables that's NOT shared but is ALSO pointed to by multiple devices. Basically the example above would be considered an invalid DT configuration. Does that sound okay to you? If I make changes to enforce that, will that be acceptable? If this sounds okay to you, then in the example above, assume Device C isn't present. Then when OPP table 1 is added by device A, if OPP table 2 hasn't been added already, I can just go ahead and allocate OPP table 2. And then when device B tries to add OPP table 2, I can just tie device B to OPP table 2 and fill up any of the missing pieces. This sounds better than trying to loop through existing OPP tables and seeing if any other table is waiting for the newly added table and marking the waiting tables as "linked". Especially because it gets a lot more complicated and inefficient when you consider a chain of OPP tables and many-to-many linking of OPP tables. -Saravana