Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp869071imj; Fri, 15 Feb 2019 08:08:07 -0800 (PST) X-Google-Smtp-Source: AHgI3IYPMkR5jDKMcMWHuadw2ez8DdOKDmfsFJoqYz2nPfKkOPQXGP3eJ8xBHH17urOp2IWxO+Qb X-Received: by 2002:a17:902:8bc6:: with SMTP id r6mr10881713plo.67.1550246887492; Fri, 15 Feb 2019 08:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550246887; cv=none; d=google.com; s=arc-20160816; b=K6LWupIspda1KtRFqDhtcA7H80KtkqZDHIpPhsMTwUHGMbBNMWylVZ4isokjeJvjBh i4DIKt78q76jJdHicCKKsjrridMS612bfWS+weA1buYYGPCkXmHGJNsIzxswKiFDE0Mh CuzT9Ei/EyQnGgpNo2vl/9Mwg0M1fU9OkSV7pSLF9eT7zU0Mu5i3LzoocvAsaaS4tKUx YsO4EZJJbnWokVfIWYoPcJx4cVc2H1ycJrLjImVtTgpOUp2N1Ej7lJklyFr4IYwxtk9g YkCSFCfU//vpeAaVlo/QlaiPfoi9uvkr9VeG3lnn16LOsdD8Ueezd/7pyMToB0cEGC/3 d9iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=04VNddYgmds17JZEJF5d0NfaR1q81VaM/WZaZGxYweA=; b=Jkp/GzpVM3GpDGfuh6LkexhHEfSfU5Ad+KSZ1cixnt3aF+H4OiL1MGfP4Uk04O46hl xa9wo3E8hUAnBdT8CIzd8J16m5rX7lyqbEYXGn5jJ5895VJORRSSo0BZftd6WtZNq7yN s0K6bHjCHdOAFQp++PQDepcwnS6LZcxAhL5Okbv1P9cfnwneQZBFBRe1s5R7XVf0T0ua MMps4a8N/eZAeEvCEdbSbu7FKC9RpechqchENhdsUhSDy86QonXfPzIjgc8dY+J3M1Gr AFKwXavmfUkdjh0/0dBOUSMq6ajZZmQrPoqbelDH5go3HoRNUnEToL5Xf8eVMMKhFQiT TLFA== 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 w31si6051634pla.308.2019.02.15.08.07.49; Fri, 15 Feb 2019 08:08:07 -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 S2393874AbfBOK0j (ORCPT + 99 others); Fri, 15 Feb 2019 05:26:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:51094 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388855AbfBOK0i (ORCPT ); Fri, 15 Feb 2019 05:26:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4EEE4AE8F; Fri, 15 Feb 2019 10:26:36 +0000 (UTC) Date: Fri, 15 Feb 2019 11:26:35 +0100 From: Petr Mladek To: John Ogness Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC PATCH v1 02/25] printk-rb: add prb locking functions Message-ID: <20190215102635.kdo4yxifh5dt2yj7@pathway.suse.cz> References: <20190212143003.48446-1-john.ogness@linutronix.de> <20190212143003.48446-3-john.ogness@linutronix.de> <20190213154541.wvft64nf352vghou@pathway.suse.cz> <87pnrvs707.fsf@linutronix.de> <20190214103324.viexpifsyons5qya@pathway.suse.cz> <87y36ih8p7.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y36ih8p7.fsf@linutronix.de> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2019-02-14 13:10:28, John Ogness wrote: > On 2019-02-14, Petr Mladek wrote: > >>> cpu_store looks like an implementation detail. The caller > >>> needs to remember it to handle the nesting properly. > >>> > >>> We could achieve the same with a recursion counter hidden > >>> in struct prb_lock. > > > > The atomic operations are tricky. I feel other lost in them. > > Well, I still think that it might easier to detect nesting > > on the same CPU, see below. > > > > Also there is no need to store irq flags in per-CPU variable. > > Only the first owner of the lock need to store the flags. The others > > are spinning or nested. > > > > struct prb_cpulock { > > atomic_t owner; > > unsigned int flags; > > int nesting; /* intialized to 0 */ > > }; > > > > void prb_lock(struct prb_cpulock *cpu_lock) > > { > > unsigned int flags; > > int cpu; > > I added an explicit preempt_disable here: > > cpu = get_cpu(); It is superfluous. Preemption is not possible when interrupts are disabled. > It looks great. I've run my stress tests on it and everything is running > well. I am glad to read this. > Thanks for simplifying this! You are welcome. Best Regards, Petr