Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1941703rdb; Tue, 5 Sep 2023 09:22:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH493/6LGEIZqEpRv/mn2toN/lmQyiiEs9uR8Po3eR1HICNLFONKsrW0L3NuNeewwl70B13 X-Received: by 2002:aa7:d059:0:b0:52a:5848:c674 with SMTP id n25-20020aa7d059000000b0052a5848c674mr257755edo.12.1693930968592; Tue, 05 Sep 2023 09:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693930968; cv=none; d=google.com; s=arc-20160816; b=RdSF1prrPDf4n7oS11nlFjkOBnY5kbBe9MJlnWgW22fhi7n6qnw4DbkFRB7BKe1o0O 7LN0xBWA4m7AGuwSGQ70iF67Q4Iw1z+EFlvKxKGenAbG40KTUE0+pFxjo2HIpIBbKlZ1 V8YHs1qikSMoKoeQ5H7WMD7c1TMgBI/gf0fveDeXO9nE9B5lVnA2u8tlaWZe6u0TEmYL gK+oznhnkhbppfM+Y78IqFH1fww9vTRxSED9bJfAbF7CfQG6yxMvCOwUSYOuv9iKb3gc Ig3KyUUsI8ciLjYGX5Menp3WqJpxCYJI9c9m9e2lvsMDWgLyBj/NUlaUXeBhohBoLICy eKig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=R646Wm+YCQhQntqAVQmIJZXlj3w5+IEPFITpKSmIxpg=; fh=xryfs/fT0DsWtrD5TuU5cB4+BOcmD90PS9ReBlVbdtw=; b=CYTruL9x/kYFqaysS8kyTQs6mo0/WW5SLYSidUMOsn1IfpJh/ez1P4ruq3dYZ9Ijj+ a9Qd+7hAcJk3qobnwYY7xzkB+cEe+WGNPcPggmpJn+5Z9RNc/3sM5uZT85YB6beV4CRx Ng0YA5h0O9x/wWUmGZocGAm6VHgtwl8ukwsHv9aItTG4GUuoNC+W1jSOiZucbh6bvbKA 67Ln9gCO7iDX/icvr3qkEnQbZfl05ZPNOEFPkwJJAOrlfsBo6p/1knABnNm8TXU/8gOL eZVu0oECaSsoLjsqpoShH1AIdBVjFfK/FsRC2ZZ8xFQdsDthsq1VEhF3zyofBb9WHPBK iHzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dpqY2j13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020aa7d38e000000b00529fc2de5easi7897317edq.535.2023.09.05.09.22.44; Tue, 05 Sep 2023 09:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dpqY2j13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345282AbjHaPY3 (ORCPT + 8 others); Thu, 31 Aug 2023 11:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231834AbjHaPY2 (ORCPT ); Thu, 31 Aug 2023 11:24:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 364FDE66 for ; Thu, 31 Aug 2023 08:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693495378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R646Wm+YCQhQntqAVQmIJZXlj3w5+IEPFITpKSmIxpg=; b=dpqY2j13g5LxfC5wcnFsCQizVnCX5zBoMjk9qz67FTPnVc3f3tYp9HyIBZHpST9LwL9edK buyovMhIxHnfLcrWv+zl6TpXpntebQGydwDJrtBh6VkPvC52/PwWZzGcnwM8Mrrr8ULFpb dU00N0zSq0pE0O1FcLXrwtMVHpKFLeo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-25-JRPeTDGkPfKOmhij0p-3ig-1; Thu, 31 Aug 2023 11:22:53 -0400 X-MC-Unique: JRPeTDGkPfKOmhij0p-3ig-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BFAB1C29AF6; Thu, 31 Aug 2023 15:22:52 +0000 (UTC) Received: from [10.22.17.50] (unknown [10.22.17.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id E670A403168; Thu, 31 Aug 2023 15:22:51 +0000 (UTC) Message-ID: Date: Thu, 31 Aug 2023 11:22:50 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v1 2/2] locking/rwsem: Make reader optimistic spinning optional Content-Language: en-US To: Bongkyu Kim , peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, kernel test robot References: <20230831030004.16576-1-bongkyu7.kim@samsung.com> <20230831030004.16576-3-bongkyu7.kim@samsung.com> From: Waiman Long In-Reply-To: <20230831030004.16576-3-bongkyu7.kim@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/30/23 23:00, Bongkyu Kim wrote: > Disable reader optimistic spinning by default. And, can enable it > by "rwsem.opt_rspin" cmdline. > > Also, fix compile error without CONFIG_RWSEM_SPIN_ON_OWNER (reported by > kernel test robot) > > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-kbuild-all/202306010043.VJHcuCnb-lkp@intel.com/ > Signed-off-by: Bongkyu Kim > --- > .../admin-guide/kernel-parameters.txt | 9 +++++++++ > kernel/locking/rwsem.c | 18 +++++++++++++++++- > 2 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 772b54df084b..adf16a07fe4d 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -5605,6 +5605,15 @@ > > rw [KNL] Mount root device read-write on boot > > + rwsem.opt_rspin [KNL] > + Use rwsem reader optimistic spinning. Reader optimistic > + spinning is helpful when the reader critical section is > + short and there aren't that many readers around. > + For example, enable this option may improve performance > + in mobile workload that there're not many readers, but > + may reduce performance in server workload that there're > + many readers. > + > S [KNL] Run init in single mode > > s390_iommu= [HW,S390] > diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c > index 9c0462d515c1..de3f173d94d4 100644 > --- a/kernel/locking/rwsem.c > +++ b/kernel/locking/rwsem.c > @@ -117,6 +117,19 @@ > # define DEBUG_RWSEMS_WARN_ON(c, sem) > #endif > > +#ifdef CONFIG_RWSEM_SPIN_ON_OWNER > +static bool rwsem_opt_rspin; You need to move this definition out of the "ifdef CONFIG_RWSEM_SPIN_ON_OWNER" block or a compilation error in rwsem_down_read_slowpath() may happen if CONFIG_RWSEM_SPIN_ON_OWNER isn't defined. You may also add __ro_after_init to rwsem_opt_rspin. Cheers, Longman > + > +static int __init opt_rspin(char *str) > +{ > + rwsem_opt_rspin = true; > + > + return 0; > +} > + > +early_param("rwsem.opt_rspin", opt_rspin); > +#endif > + > /* > * On 64-bit architectures, the bit definitions of the count are: > * > @@ -1083,7 +1096,7 @@ static inline bool rwsem_reader_phase_trylock(struct rw_semaphore *sem, > return false; > } > > -static inline bool rwsem_no_spinners(sem) > +static inline bool rwsem_no_spinners(struct rw_semaphore *sem) > { > return false; > } > @@ -1157,6 +1170,9 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat > return sem; > } > > + if (!IS_ENABLED(CONFIG_RWSEM_SPIN_ON_OWNER) || !rwsem_opt_rspin) > + goto queue; > + > /* > * Save the current read-owner of rwsem, if available, and the > * reader nonspinnable bit.