Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5873770rwb; Tue, 9 Aug 2022 05:40:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR6CqyzXzkIBEZGNUe2HcYfe8ThHmeITEPl8P4XpPEU0xOqpYBMLBnKMc+GT4uaMUlXDMtkR X-Received: by 2002:a17:902:d48a:b0:16f:c31:7005 with SMTP id c10-20020a170902d48a00b0016f0c317005mr23127948plg.173.1660048821921; Tue, 09 Aug 2022 05:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660048821; cv=none; d=google.com; s=arc-20160816; b=RE1BNCHs0o9kmcVLEreBzjg6PbDSRKv+QBzZOUtlFK7n8vklFKlNsSjR7150sh6bHr eL5QEHW7lIDDCW4DRNhlZp53aQ6ucYHvxO8LxB+nDZnTSMAljInB4koU1CserXtqJGaV LBG0IhZHAovzolrCj8G0Zajt3gfAG6eHN8ojXymBCW4EY8N9fb4EGKnA6l1YWKiTDysx pfzuJcMBF8zIsLFjbTlc4wgv2zyb3nZIHVFxuz76MIRMqQNHXCamZAHvOwA/+BqMRpxq P/TY8e48ggH7yiejkWv5ABLmOJD1ZyaG1noICe9wpAXAHyC03U/xkl+WpW/FVaqCi6hg 3VsQ== 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=3+KBkpV9m1bxJhsMtzeVGV+drTP66AAmd/wpftn5OL4=; b=lSdovJkN4/rG2Woun73Idc87fHcwbvddA0vA61A/qDTPdIhTt4zg7WBBmsditni4eQ KqY8wAVqMu8MIRP32hAEtOLxx/zi1jBjp7dMI/cixGCBN+xLmjA15MwF/vTCorXKdQhZ AglRZ3s3dOBvnPDa4wTSz9sOWFZhm7pwhNoQc5D7G+3rBnU4auMWlmh12cg4jrKe8ydQ 9JXCWFV1p3PiclX624vIS/Kuhz7y75Vmu5fW4kQt1eSvuwz8Dxme/5NDtoFfO73f+SDp tmueEzTi78LnvnBceAJJl/QvDs7Tv7CgQudvwErLNXJXiOKUdan63pSt6+CjgCXC8nWZ 0n8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=E6FupvpT; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020a056a001a1100b00527d7f8e7ebsi15301086pfv.274.2022.08.09.05.40.06; Tue, 09 Aug 2022 05:40:21 -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=@rasmusvillemoes.dk header.s=google header.b=E6FupvpT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230380AbiHIM32 (ORCPT + 99 others); Tue, 9 Aug 2022 08:29:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbiHIM30 (ORCPT ); Tue, 9 Aug 2022 08:29:26 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B84B13EA9 for ; Tue, 9 Aug 2022 05:29:24 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id s9so12825030ljs.6 for ; Tue, 09 Aug 2022 05:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=3+KBkpV9m1bxJhsMtzeVGV+drTP66AAmd/wpftn5OL4=; b=E6FupvpTXxk3V7KyG/UrXwV0+9ePJHgQQbeBBwxS0LtgXCHuLfAblq2be3zPHNhFB/ vU1EKkk3gRW0HTgiBX5BfrJuD1WggYV2YPN8v3MuvYDa3wYj8nRV2W4n1joyK0aa1b+4 l8DJQzOPlXgjSBkJWS4VIsnVC0XlC5ryT1cJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=3+KBkpV9m1bxJhsMtzeVGV+drTP66AAmd/wpftn5OL4=; b=AoluTHO3U3NTBuysHYSjALKBh5v8g1UrFRrhgdOvQmXblU2uCWvYzsCW3WQurQoBf+ +B/jUUhg3v9y14CpKEDCI/VNFua1n3/t/5DIP9PW0QFy106VY4IYISzWXxAjuek8Zi1r o999lb9cAyxVvJsc5rqEGaryvCE4tisKxpyF/8KZybKhw7ManY5wy5+JzEN2giTeYz6i y8w5jnTbZgjrdMbT+r/F0xszExROmpw0g9/2C3Ds8kPoQpsUUn1UXkpmdsw1Gm4fCLl0 X9P16XwfHlU8jRjmrdMxuP7TfRirleraRrLuLEuV7C1DFu2Vx4HeUuF8Cc/i6iw95Bf1 pnDg== X-Gm-Message-State: ACgBeo2OhfyymXWIyZ832C4fuIUKJ4LtJ6DYGn8P99Gb+MZnC/yv14cH 88gw88PhdupSoumk7LhpX/woZA== X-Received: by 2002:a2e:8008:0:b0:25f:dd78:8312 with SMTP id j8-20020a2e8008000000b0025fdd788312mr3002868ljg.127.1660048162776; Tue, 09 Aug 2022 05:29:22 -0700 (PDT) Received: from [172.16.11.74] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id y8-20020ac24208000000b0047f8e9826a1sm1752461lfh.31.2022.08.09.05.29.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Aug 2022 05:29:19 -0700 (PDT) Message-ID: <79b1b62c-8ea1-5f47-bf80-3e003f7a3ac7@rasmusvillemoes.dk> Date: Tue, 9 Aug 2022 14:29:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 11/16] time: optimize tick_check_preferred() Content-Language: en-US To: Yury Norov , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Alexander Lobakin , Alexei Starovoitov , Alexey Klimov , Andrew Morton , Andrii Nakryiko , Andy Shevchenko , Ben Segall , Christoph Lameter , Dan Williams , Daniel Borkmann , Daniel Bristot de Oliveira , Dennis Zhou , Dietmar Eggemann , Eric Dumazet , Frederic Weisbecker , Guenter Roeck , Ingo Molnar , Isabella Basso , John Fastabend , Josh Poimboeuf , Juergen Gross , Juri Lelli , KP Singh , Kees Cook , Martin KaFai Lau , Mel Gorman , Miroslav Benes , Nathan Chancellor , "Paul E . McKenney" , Peter Zijlstra , Randy Dunlap , Sebastian Andrzej Siewior , Song Liu , Steven Rostedt , Tejun Heo , Valentin Schneider , Vincent Guittot , Vlastimil Babka , Yonghong Song , linux-mm@kvack.org, netdev@vger.kernel.org, bpf@vger.kernel.org References: <20220718192844.1805158-1-yury.norov@gmail.com> <20220718192844.1805158-12-yury.norov@gmail.com> <87fsi9rcxu.ffs@tglx> <87czdbq7up.ffs@tglx> From: Rasmus Villemoes In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 08/08/2022 18.38, Yury Norov wrote: > On Mon, Aug 08, 2022 at 01:42:54PM +0200, Thomas Gleixner wrote: >> On Sat, Aug 06 2022 at 10:30, Thomas Gleixner wrote: >>> On Mon, Jul 18 2022 at 12:28, Yury Norov wrote: >>> >>>> tick_check_preferred() calls cpumask_equal() even if >>>> curdev->cpumask == newdev->cpumask. Fix it. >>> >>> What's to fix here? It's a pointless operation in a slow path and all >>> your "fix' is doing is to make the code larger. > > Pointless operation in a slow path is still pointless. > >> In fact cpumask_equal() should have the ptr1 == ptr2 check, so you don't >> have to add it all over the place. > > This adds to the image size: > add/remove: 1/1 grow/shrink: 24/3 up/down: 507/-46 (461) > > The more important, cpumask shouldn't check parameters because this is > an internal function. This whole series point is about adding such checks > under DEBUG_BITMAP config, and not affecting general case. Yury, calling bitmap_equal (and by extension cpumask_equal) with something that happens in some cases to be the same pointer for both operands is not a bug. If you want to optimize that case, add a check in __bitmap_equal(), it will add a few bytes (maybe 2-4 instructions) to the kernel image, much less than what this whole series does by open-coding that check all over, and since it's comparing two registers, it won't in any way affect the performance of the case where the pointers are distinct. Rasmus