Received: by 10.223.148.5 with SMTP id 5csp6832382wrq; Wed, 17 Jan 2018 20:02:53 -0800 (PST) X-Google-Smtp-Source: ACJfBosr4U7oyp6M24mrMX3gHXcfZDVLHdyXywVc5sLCPwGycCnp8SrBsu+UjTD+DtvHjTBmq1VP X-Received: by 10.159.230.16 with SMTP id u16mr29712330plq.401.1516248173474; Wed, 17 Jan 2018 20:02:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516248173; cv=none; d=google.com; s=arc-20160816; b=EGaa/RInW0HTgHEcT+UWTPr6OZo73fBiLIi5IxvFTUEJVPd2CDBuY4NHzHvZamibEA 2kgnoiEpYzIbCOiviFMU7pwliWNdGsYEpdOxLcxl/Ytv2lxKBab0y3HhRUlHfbC6yP34 NtNMvIigpEVpR7Oc4HRxORb2V9fvZ4ev8LpHrh4eOd/ORyw2bAdJaoNsC07GAQykr+CA o21Yc17WD6v3LtZyzpaS7UJhrHRp4iple2VfOMgSIIkUtBH9N5Sd0tdH0edCnUaPRbtM EPZD4LpIBYFjZ8M8DnGBrjY+5pPGGGQfX/VKsoxMuhE02kH1QndLmj0ti8C7kWvkKaXe 7s8g== 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:arc-authentication-results; bh=/LiMmSA4wO1IdMPYOIMqJwdzLN6bHuvN6dN9Adf6skI=; b=rywh4hYB6JFkMnI6mHmd696dBVnJp2yDs75hDmJWj/EybOk9Z/Rayj/8BMa02ZkbFe EeJYU+7FXICh4tnIATZGThMsIHuwCM1l6ZXfKlTM1waFN6BC2aJ+A9KgZmWBKL6qNMVw SZH6vFK2oMwD0ccl8JP5x4QE0UvtH7jGxfaxOdaIp5dFRsMepCMhESpGPZ/Vqaeys4Kg qIVVp50e3AowKa/TzNhbGQkzbGQu8WPW7/OeNw8LSV3avGDhqcIb21Y0cf1sNMHV6Iid 0CiHACIZ3eROLHd0XDh2diNZn4//pYuWXHiCvhFewMEFnyV5To//Zox+PlDAgdqn171H /zrA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si5651124pfb.291.2018.01.17.20.02.29; Wed, 17 Jan 2018 20:02:53 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753618AbeAREBv (ORCPT + 99 others); Wed, 17 Jan 2018 23:01:51 -0500 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:52830 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753279AbeAREBt (ORCPT ); Wed, 17 Jan 2018 23:01:49 -0500 Received: from unknown (HELO lgeamrelo01.lge.com) (156.147.1.125) by 156.147.23.53 with ESMTP; 18 Jan 2018 13:01:47 +0900 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO ?10.177.222.184?) (10.177.222.184) by 156.147.1.125 with ESMTP; 18 Jan 2018 13:01:46 +0900 X-Original-SENDERIP: 10.177.222.184 X-Original-MAILFROM: byungchul.park@lge.com Subject: Re: [PATCH v5 1/2] printk: Add console owner and waiter logic to load balance console writes To: Steven Rostedt Cc: Petr Mladek , Sergey Senozhatsky , akpm@linux-foundation.org, linux-mm@kvack.org, Cong Wang , Dave Hansen , Johannes Weiner , Mel Gorman , Michal Hocko , Vlastimil Babka , Peter Zijlstra , Linus Torvalds , Jan Kara , Mathieu Desnoyers , Tetsuo Handa , rostedt@home.goodmis.org, Sergey Senozhatsky , Tejun Heo , Pavel Machek , linux-kernel@vger.kernel.org, kernel-team@lge.com References: <20180110132418.7080-1-pmladek@suse.com> <20180110132418.7080-2-pmladek@suse.com> <20180117120446.44ewafav7epaibde@pathway.suse.cz> <4a24ce1d-a606-3add-ec30-91ce9a1a1281@lge.com> <20180117211953.2403d189@vmware.local.home> From: Byungchul Park Message-ID: <171cf5b9-2cb6-8e70-87f5-44ace35c2ce4@lge.com> Date: Thu, 18 Jan 2018 13:01:46 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180117211953.2403d189@vmware.local.home> 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 On 1/18/2018 11:19 AM, Steven Rostedt wrote: > On Thu, 18 Jan 2018 10:53:37 +0900 > Byungchul Park wrote: > >> Hello, >> >> This is a thing simulating a wait for an event e.g. >> wait_for_completion() doing spinning instead of sleep, rather >> than a spinlock. I mean: >> >> This context >> ------------ >> while (READ_ONCE(console_waiter)) /* Wait for the event */ >> cpu_relax(); >> >> Another context >> --------------- >> WRITE_ONCE(console_waiter, false); /* Event */ > > I disagree. It is like a spinlock. You can say a spinlock() that is > blocked is also waiting for an event. That event being the owner does a > spin_unlock(). That's exactly what I was saying. Excuse me but, I don't understand what you want to say. Could you explain more? What do you disagree? >> >> That's why I said this's the exact case of cross-release. Anyway >> without cross-release, we usually use typical acquire/release >> pairs to cover a wait for an event in the following way: >> >> A context >> --------- >> lock_map_acquire(wait); /* Or lock_map_acquire_read(wait) */ >> /* Read one is better though.. */ >> >> /* A section, we suspect, a wait for an event might happen. */ >> ... >> lock_map_release(wait); >> >> >> The place actually doing the wait >> --------------------------------- >> lock_map_acquire(wait); >> lock_map_acquire(wait); >> >> wait_for_event(wait); /* Actually do the wait */ >> >> You can see a simple example of how to use them by searching >> kernel/cpu.c with "lock_acquire" and "wait_for_completion". >> >> However, as I said, if you suspect that cpu_relax() includes >> the wait, then it's ok to leave it. Otherwise, I think it >> would be better to change it in the way I showed you above. > > I find your way confusing. I'm simulating a spinlock not a wait for > completion. A wait for completion usually initiates something then I used the word, *event* instead of *completion*. wait_for_completion() and complete() are just an example of a pair of waiter and event. Lock and unlock can also be another example, too. Important thing is that who waits and who triggers the event. Using the pair, we can achieve various things, for examples: 1. Synchronization like wait_for_completion() does. 2. Control exclusively entering into a critical area. 3. Whatever. > waits for it to complete. This is trying to get into a critical area > but another task is currently in it. It's simulating a spinlock as far > as I can see. Anyway it's an example of "waiter for an event, and the event". JFYI, spinning or sleeping does not matter. Those are just methods to achieve a wait. I know you're not talking about this though. It's JFYI. -- Thanks, Byungchul