Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3835768ybx; Mon, 4 Nov 2019 03:42:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzCoHrH9fvFpDWsGxLSgdqauc64iwt9mzYd2HTA5y1Dp/ZTIY+wMSI36zg84rw7HXsSqknF X-Received: by 2002:a17:906:c44f:: with SMTP id ck15mr23209945ejb.7.1572867755036; Mon, 04 Nov 2019 03:42:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572867755; cv=none; d=google.com; s=arc-20160816; b=YtycgPWbK997p91eNt71aRmaScS7iaEXBVv0b/W4wjRWXH/Ev09VzJnY7olUIyoJGC UV09GZ7rvdLckv3ZCibKDSZM3KEjoMUao/x+R1yF7yMgar/wadyGdYRInb77HfhUlZbS bjcDx/+G991al2rBYc/917mU1+rs25vW64SEbsJH02azyLhMpGiMdr/tQLIXqsOSiJDe vU2mNN02LhYtYk6U+Fbzy4dswC/MyAkSAqiTnbYapeJhFHHpVCaTL2oi5+mwGpNk72oj GSG3XH+YZlmo+zn20fBPpoZGJUN3k5D4ZTOGmlQlr3KHf8K9s18ZXUJq/bheVqVSbS3O RAlg== 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; bh=cal5VtZrl/t5W8DgauhsOH4vo6q2e1PAeoqZdl6ryGU=; b=rTlJmlEXR+csPZTKU3Z7yz+qZEK6Nc+2dq+PBnY0x6t8AhmvIv/29VW3AF7DQxbi4W DqesP1j0UF5wh8jWq+duxcs0ZjToB5uCmtV3TE9WBUh4IUUQ2/oNMdVQa75g09qRJeOf RJHKhOwyxeHguvm+x6gHO7473wZozv8fgUQlNWvk/hyZ3TFsEZosLBj9scS/5hjYe9pE kre37Z9lY2kXKx9PS8YrekXIag12rYZdNVnE8ZcwCxJwHLG3IFc++KxxP6HyyUmqHSmT 7noeiDLBgzSN7qYrqi5r04o2K3UaqcA+vBRUGBNwr9XS/+byapwFifoXrSQaO1YD8K1z hfQg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si6914203eda.258.2019.11.04.03.42.11; Mon, 04 Nov 2019 03:42:35 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728715AbfKDLla (ORCPT + 99 others); Mon, 4 Nov 2019 06:41:30 -0500 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:56996 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbfKDLla (ORCPT ); Mon, 4 Nov 2019 06:41:30 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R401e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=laijs@linux.alibaba.com;NM=1;PH=DS;RN=36;SR=0;TI=SMTPD_---0ThBi2ca_1572867681; Received: from C02XQCBJJG5H.local(mailfrom:laijs@linux.alibaba.com fp:SMTPD_---0ThBi2ca_1572867681) by smtp.aliyun-inc.com(127.0.0.1); Mon, 04 Nov 2019 19:41:22 +0800 Subject: Re: [PATCH V2 7/7] x86,rcu: use percpu rcu_preempt_depth To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , Andi Kleen , Andy Lutomirski , Fenghua Yu , Kees Cook , "Rafael J. Wysocki" , Dave Hansen , Babu Moger , Rik van Riel , "Chang S. Bae" , Jann Horn , David Windsor , Elena Reshetova , Yuyang Du , Anshuman Khandual , Richard Guy Briggs , Andrew Morton , Christian Brauner , Michal Hocko , Andrea Arcangeli , Al Viro , "Dmitry V. Levin" , rcu@vger.kernel.org References: <20191102124559.1135-1-laijs@linux.alibaba.com> <20191102124559.1135-8-laijs@linux.alibaba.com> <20191104092519.nukaz5qmgiskzafi@linutronix.de> From: Lai Jiangshan Message-ID: <4878ccfd-7a4e-4f84-9bc3-1d477e077587@linux.alibaba.com> Date: Mon, 4 Nov 2019 19:41:20 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191104092519.nukaz5qmgiskzafi@linutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/11/4 5:25 下午, Sebastian Andrzej Siewior wrote: > On 2019-11-02 12:45:59 [+0000], Lai Jiangshan wrote: >> Convert x86 to use a per-cpu rcu_preempt_depth. The reason for doing so >> is that accessing per-cpu variables is a lot cheaper than accessing >> task_struct or thread_info variables. > > Is there a benchmark saying how much we gain from this? Hello Maybe I can write a tight loop for testing, but I don't think anyone will be interesting in it. I'm also trying to find some good real tests. I need some suggestions here. > >> We need to save/restore the actual rcu_preempt_depth when switch. >> We also place the per-cpu rcu_preempt_depth close to __preempt_count >> and current_task variable. >> >> Using the idea of per-cpu __preempt_count. >> >> No function call when using rcu_read_[un]lock(). >> Single instruction for rcu_read_lock(). >> 2 instructions for fast path of rcu_read_unlock(). > > I think these were not inlined due to the header requirements. objdump -D -S kernel/workqueue.o shows (selected fractions): raw_cpu_add_4(__rcu_preempt_depth, 1); d8f: 65 ff 05 00 00 00 00 incl %gs:0x0(%rip) # d96 ...... return GEN_UNARY_RMWcc("decl", __rcu_preempt_depth, e, __percpu_arg([var])); dd8: 65 ff 0d 00 00 00 00 decl %gs:0x0(%rip) # ddf if (unlikely(rcu_preempt_depth_dec_and_test())) ddf: 74 26 je e07 ...... rcu_read_unlock_special(); e07: e8 00 00 00 00 callq e0c > > Boris pointed one thing, there is also DEFINE_PERCPU_RCU_PREEMP_DEPTH. > Thanks for pointing out. Best regards Lai