Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1801829rdd; Thu, 11 Jan 2024 09:35:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUobD80HWiJTm8wG2/f5ykcMEYscMyLzzY2mG29bvNyuG77wiJHKZ3iZ4ldWWBytjFPHv5 X-Received: by 2002:a17:906:264f:b0:a27:4821:756d with SMTP id i15-20020a170906264f00b00a274821756dmr12427ejc.38.1704994548480; Thu, 11 Jan 2024 09:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704994548; cv=none; d=google.com; s=arc-20160816; b=x1BODFzZOCTFmfKkrTJgBwRL5oMEwbkkAY2M0ZWZ1VNpMWbPMAQ7M7M5Wg6rJgiULc 93KX66eUvS4w3UVAh0URx6FOJONaSBC+su5SLSsKay1nqp9UilP82Sv0GGjYxXDu0mh7 tZRGhOMsHpKuoTNw5nk2fKWfRGBwscnelCiyZzOq2QVVkd0DvFQTOGekIFYGfo553Hwx cKHMX1yZXNmXvBZ1gDkGJhTGBOMlDQDZKvdGsRVQbkO1dK+JW9Psg9uuk5rR6O14PqQ1 Vj4N7GM2p0HbGK3T6k8lbwJBWwNrwUaQH+cyQnK5FhUGG1KsApe+utJdJOVwUwjFj8Z8 m25A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:date:from:dkim-signature; bh=kYTLvTHP6c15eJsjLaYySaO8Yr732/QLsj7CRRlVDCY=; fh=XKg5GzotX7m6IJTiFTDRy3QyR79xH/i3jJc3DlzRWAQ=; b=zBzB3SS9vdsS7KL1FDsETxkW/Vely86PL2EGR8VzW2u3RBY7NDyGrJbIAd6Lx6BLlz W9fRHgGnRggc5I5Ytt6UZHZa5/oE8H01qnue/yLbsyQ/p4BSBUZB9IdjgRHbaG7AKNVC hcCX2lFCMGA4x3QVO2lpV+lRRWFWdn4tULyK4SJDpxo7QsBgf7RFUbXxNQWB909aErUT Ddv3uU7S1MOViAmhr4lvg6WVf7doUjnzfJDk4mM1OijGfC/kyTmnexSsy7t6+rDvIG+W VzKrbrhxsQX5ioqYitVPfu7ze9WyUCULnSSGYjBbQNDRu+n0WBUCtU4k0E3hhFw0JhuU Vu8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YWT2UnzZ; spf=pass (google.com: domain of linux-kernel+bounces-23939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ay20-20020a170906d29400b00a2706ea4afdsi674889ejb.787.2024.01.11.09.35.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 09:35:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YWT2UnzZ; spf=pass (google.com: domain of linux-kernel+bounces-23939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0E4CC1F24818 for ; Thu, 11 Jan 2024 17:35:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74524524C1; Thu, 11 Jan 2024 17:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YWT2UnzZ" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E4FB51007; Thu, 11 Jan 2024 17:35:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-50e7dd8bce8so6549752e87.1; Thu, 11 Jan 2024 09:35:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704994533; x=1705599333; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=kYTLvTHP6c15eJsjLaYySaO8Yr732/QLsj7CRRlVDCY=; b=YWT2UnzZ6njsWjbg3MvEpig9/ywlkkwfuE8gLjCNWKr1e9Pq2yXHwxoHlXnP3WMOA4 qTiA35urWjLEb8b3/gtSTwaDYQY4yOAxlJWD1EUqWWDi/9VYuorq5FASsKDWg3R6fcld O6WC9Li4j7du43ThyKIMMmL699QKDhYy41WWxHM79/5cjmSZuGZVwx9S23NIOiZgX3aq g/+SHPNSi+CdkJDog45HNrfrhJFuEmdX/ywJbuhow6Sp8HiXw4CVv2vS2HqI2Thy++QX Uz0yfkpF78ymljSifiBz8exEldjudWQtmLWSHx4H5GoztRlBDpPjQUonKqaHI6Th5tBS BEow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704994533; x=1705599333; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kYTLvTHP6c15eJsjLaYySaO8Yr732/QLsj7CRRlVDCY=; b=hikrU0FkLYmkAio0RKzmqVJZdbqjco5WbOm/vV+0ImEKYl7DUt2zyjZH6rYw+nZ5cD Q13R9JcvoGP/KWy1XQiz7ysGQM2LGrzyWi72jQKLbL8vOSDRF3Hqm2KDddOvBC8r1P2w cjea6Z9nPmJRAE7HqPAhFm4dIuAWL1hsTguu2XNqkGYxt6/LqjWtJC4ISuWe5qNUAo+O /ALwtsaedwiCGEGd+64PonlzH0gzo2B7B1y8ioa40y3IOPcQauPjULc9PTkAGKBnExjV g8TedENNBLuNuuY7zPWXgL/RrfgsuHowmeKMTF9IklrcVT76yw/+CjOLyMGAa8xnxlXU O6Lg== X-Gm-Message-State: AOJu0YzVQXoT7avUTkkEiUd+RegE9VbQFf+emHboV1dr0EK4bWKNT3h6 G8JB6Bz3VWiVTHnb5s/QLWk= X-Received: by 2002:a19:7413:0:b0:50b:f279:cab with SMTP id v19-20020a197413000000b0050bf2790cabmr25279lfe.51.1704994533070; Thu, 11 Jan 2024 09:35:33 -0800 (PST) Received: from pc636 (host-90-233-192-22.mobileonline.telia.com. [90.233.192.22]) by smtp.gmail.com with ESMTPSA id y20-20020ac255b4000000b0050e7ee56355sm255564lfg.23.2024.01.11.09.35.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 09:35:32 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Thu, 11 Jan 2024 18:35:30 +0100 To: Kalesh Singh Cc: Uladzislau Rezki , "Paul E . McKenney" , RCU , Neeraj upadhyay , Boqun Feng , Hillf Danton , Joel Fernandes , LKML , Oleksiy Avramchenko , Frederic Weisbecker Subject: Re: [PATCH v4 1/4] rcu: Reduce synchronize_rcu() latency Message-ID: References: <20240104162510.72773-1-urezki@gmail.com> <20240104162510.72773-2-urezki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hello, Kalesh! > > > > > > > > Hi Uladzislau, > > > > > > I've tried your patches (v3) on Android with 6.1.43 kernel. > > > > > > The test cycles 10 apps (including camera) sequentially for 100 > > > iterations. > > > > > > I've set rcu_normal to override the rcu_expedited in the boot > > > parameters: > > > > > > adb shell cat /proc/cmdline | tr ' ' '\n' | grep rcu > > > > > > rcupdate.rcu_normal=1 > > > rcupdate.rcu_expedited=1 > > > rcu_nocbs=0-7 > > > > > > > > > The configurations are: > > > > > > A - echo 0 >/sys/module/rcutree/parameters/rcu_normal_wake_from_gp > > > B - echo 1 >/sys/module/rcutree/parameters/rcu_normal_wake_from_gp > > > > > > Results: > > > > > > = APP LAUNCH TIME = > > > delta (B-A) ratio(%) > > > overall_app_launch_time(ms) -11399.00 -6.65 > > > > > > > > > == camera_launch_time > > > type delta(B-A %) A_count B_count > > > HOT -7.05 99 99 > > > COLD -6.33 1 1 > > > > > > > > Hi Uladzislau, > > > If i interpret it correctly you also see that this series reduces > > a launch time by 6/7% on your app set. Is that correct? > > Yes your understanding is correct. > > > > > > === Function Latencies === > > > > > > Tracing synchronize_rcu_expedited. Hit Ctrl-C to exit Tracing synchronize_rcu_expedited. Hit Ctrl-C to exit > > > > > > nsec : count distribution nsec : count distribution > > > 0 -> 1 : 0 | | 0 -> 1 : 0 | | > > > 2 -> 3 : 0 | | 2 -> 3 : 0 | | > > > 4 -> 7 : 0 | | 4 -> 7 : 0 | | > > > 8 -> 15 : 0 | | 8 -> 15 : 0 | | > > > 16 -> 31 : 0 | | 16 -> 31 : 0 | | > > > 32 -> 63 : 0 | | 32 -> 63 : 0 | | > > > 64 -> 127 : 0 | | 64 -> 127 : 0 | | > > > 128 -> 255 : 0 | | 128 -> 255 : 0 | | > > > 256 -> 511 : 0 | | 256 -> 511 : 0 | | > > > 512 -> 1023 : 0 | | 512 -> 1023 : 0 | | > > > 1024 -> 2047 : 0 | | 1024 -> 2047 : 0 | | > > > 2048 -> 4095 : 0 | | 2048 -> 4095 : 0 | | > > > 4096 -> 8191 : 0 | | 4096 -> 8191 : 0 | | > > > 8192 -> 16383 : 0 | | 8192 -> 16383 : 0 | | > > > 16384 -> 32767 : 0 | | 16384 -> 32767 : 0 | | > > > 32768 -> 65535 : 0 | | 32768 -> 65535 : 0 | | > > > 65536 -> 131071 : 0 | | 65536 -> 131071 : 0 | | > > > 131072 -> 262143 : 0 | | 131072 -> 262143 : 0 | | > > > 262144 -> 524287 : 0 | | 262144 -> 524287 : 0 | | > > > 524288 -> 1048575 : 0 | | 524288 -> 1048575 : 0 | | > > > 1048576 -> 2097151 : 0 | | 1048576 -> 2097151 : 0 | | > > > 2097152 -> 4194303 : 0 | | 2097152 -> 4194303 : 0 | | > > > 4194304 -> 8388607 : 871 |** | 4194304 -> 8388607 : 1180 |**** | > > > 8388608 -> 16777215 : 3204 |******** | 8388608 -> 16777215 : 7020 |************************* | > > > 16777216 -> 33554431 : 15013 |****************************************| 16777216 -> 33554431 : 10952 |****************************************| > > > Exiting trace of synchronize_rcu_expedited Exiting trace of synchronize_rcu_expedited > > > > > > > > > Tracing synchronize_rcu. Hit Ctrl-C to exit Tracing synchronize_rcu. Hit Ctrl-C to exit > > > > > > nsec : count distribution nsec : count distribution > > > 0 -> 1 : 0 | | 0 -> 1 : 0 | | > > > 2 -> 3 : 0 | | 2 -> 3 : 0 | | > > > 4 -> 7 : 0 | | 4 -> 7 : 0 | | > > > 8 -> 15 : 0 | | 8 -> 15 : 0 | | > > > 16 -> 31 : 0 | | 16 -> 31 : 0 | | > > > 32 -> 63 : 0 | | 32 -> 63 : 0 | | > > > 64 -> 127 : 0 | | 64 -> 127 : 0 | | > > > 128 -> 255 : 0 | | 128 -> 255 : 0 | | > > > 256 -> 511 : 0 | | 256 -> 511 : 0 | | > > > 512 -> 1023 : 0 | | 512 -> 1023 : 0 | | > > > 1024 -> 2047 : 0 | | 1024 -> 2047 : 0 | | > > > 2048 -> 4095 : 0 | | 2048 -> 4095 : 0 | | > > > 4096 -> 8191 : 0 | | 4096 -> 8191 : 0 | | > > > 8192 -> 16383 : 0 | | 8192 -> 16383 : 0 | | > > > 16384 -> 32767 : 0 | | 16384 -> 32767 : 0 | | > > > 32768 -> 65535 : 0 | | 32768 -> 65535 : 0 | | > > > 65536 -> 131071 : 0 | | 65536 -> 131071 : 0 | | > > > 131072 -> 262143 : 0 | | 131072 -> 262143 : 0 | | > > > 262144 -> 524287 : 0 | | 262144 -> 524287 : 0 | | > > > 524288 -> 1048575 : 0 | | 524288 -> 1048575 : 0 | | > > > 1048576 -> 2097151 : 0 | | 1048576 -> 2097151 : 0 | | > > > 2097152 -> 4194303 : 0 | | 2097152 -> 4194303 : 0 | | > > > 4194304 -> 8388607 : 861 |** | 4194304 -> 8388607 : 1136 |**** | > > > 8388608 -> 16777215 : 3111 |******** | 8388608 -> 16777215 : 6320 |************************ | > > > 16777216 -> 33554431 : 13901 |****************************************| 16777216 -> 33554431 : 10484 |****************************************| > > > Exiting trace of synchronize_rcu Exiting trace of synchronize_rcu > > > > > Who is B and who is A? > > Left is A (rcu_normal_wake_from_gp=0) and right is B > (rcu_normal_wake_from_gp=1) > > > > > > > > Interestingly I tried the same experiment without rcu_normal=1 (leaving rcu_expedited=1): > > > > > > adb shell cat /proc/cmdline | tr ' ' '\n' | grep rcu > > > rcupdate.rcu_expedited=1 > > > rcu_nocbs=0-7 > > > > > > In this case I also saw the -6 to -7% decrease in the app launch times > > > but I don't have a good explanation why that would be? (The fucntion > > > latency histograms in this case didn't show any significant difference). > > > Do you have any insight why this may happen? > > > > > When rcu_expedited=1 is set and rcu_normal=0 is disabled. The > > synchronize_rcu() call is converted into synchronize_rcu_expidited(): > > > > > > void synchronize_rcu(void) > > { > > unsigned long flags; > > struct rcu_node *rnp; > > > > RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map) || > > lock_is_held(&rcu_lock_map) || > > lock_is_held(&rcu_sched_lock_map), > > "Illegal synchronize_rcu() in RCU read-side critical section"); > > if (!rcu_blocking_is_gp()) { > > if (rcu_gp_is_expedited()) > > synchronize_rcu_expedited(); > > else > > synchronize_rcu_normal(); > > return; > > } > > ... > > > > > > rcu_gp_is_expidited() is true, so invoke "expedited" version. > > > > I see some concerns in preferring an expedited version as a global > > replacement. First of all it is related to latency sensitive workloads > > because in order to expedite a grace period it sends out IPIs on all > > online CPUs to force them to report a quiescent-state asap. I have not > > investigated yet how it affects such workloads. > > > > Therefore, in your case, you also see a performance boost of your app sets. > > IIUC the patch shouldn't affect the case? The only difference in A vs > B is rcu_normal_wake_from_gp (both have rcu_expedited=1). > Right. This patch does not touch "expedited" version at all. Appreciate for test results and looking at! -- Uladzislau Rezki