Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp330482rwi; Thu, 27 Oct 2022 01:39:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Vfc0q/TPhdHGqVSztotjSMeu+nyRftXojMNZ+CE1Vh4mW4M+1eyBjd4K47rBfdhEXCLzc X-Received: by 2002:a05:6402:40d0:b0:462:7b99:d424 with SMTP id z16-20020a05640240d000b004627b99d424mr4291621edb.62.1666859970106; Thu, 27 Oct 2022 01:39:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666859970; cv=none; d=google.com; s=arc-20160816; b=nu0RpCKOkuVxAfKo1pew4Fqt0N1vTMf1SgAFJ1bTieRBXsVGLGdt/Dg2cKceaCp1bS e42cYgeA4fMYu6vJYuOoRTXXtLu92KSCRPmI0tVPTg1mBz8WFQlPSUbl4kNjXVM/3/Ne EyeYk+l/i2EyRiMmxLnaRJEIgLlL3lxU+tc8KfMonzGmm1njgWE2RzbY8LNyMEgZg1Um D0kGFzrzD+4sVNEzuRlV2qLOMoVKZ1RVCyi734zx5+fcADLkqplrYK9NxjzivMF0DaVa Kk/RHAdppYsNCSLzGauM1yhOuoHKUVdUfQefwhrF5TrDhSZpb1YzhxD5pQBxZt1hdwI2 6AGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RO3+Ms54cmiEAtpIFy0zI5rJu5Dg4jt0Si4uzbTVVAs=; b=Y8wfxtT+t44XnqawZn846TN+xBQG0IzOQ11FGY2gP1paSWkDkziRdEEd+VjToK521g ihILk2p5w+MNDIiBCW3cPy5p7zQhqbaNmLDvacTiqxsDkrJClsewqcV5fiGBUMYNVZIV iITLjLIDXVk1sFnnWfo1errqp/yljiFN81xhjbgFNhVZxDJSTB2mgPbHXvQeoFu+YYJE eHJrGBjKXE4wvdKkAJMtaBSqcyupnvPME6jsdqMnRlM3MvELt65+DDoIJ7J1v08t5ldM HWwgKpNInmOHVromNyDPkPM/eWgUmw6S2WuEUk/yrcMQSF5SV41QorzcLTykYjLx4xV/ xgaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=brzCsqRE; 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 h3-20020a0564020e0300b00461ebe2a168si1028553edh.447.2022.10.27.01.39.02; Thu, 27 Oct 2022 01:39:30 -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=@infradead.org header.s=casper.20170209 header.b=brzCsqRE; 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 S234717AbiJ0Hyq (ORCPT + 99 others); Thu, 27 Oct 2022 03:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234608AbiJ0Hyi (ORCPT ); Thu, 27 Oct 2022 03:54:38 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B40D627B for ; Thu, 27 Oct 2022 00:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=RO3+Ms54cmiEAtpIFy0zI5rJu5Dg4jt0Si4uzbTVVAs=; b=brzCsqRECX0WGxeVNZX14pXjPI 1Hw+qgYmIPcD8h/lzfAvuwX5l0CRt3G5Xe82cvHHamQnsYpc3Xp5jaeLC+1lZXS9GG/ERiWiYQIhG Ve1ZLE5U8jR4AqQRlBfvnN3zZj4DSqrVelJG8i05Qw9JXXh4MWtKVz7dYmtFp0DK+A4MNZc1QYvaG 34WVVOpgJHJD5xawDGcFlWrj3LPqfA0ivJog2GeSSG4dCZ6D4vPYVqVvieE+JqG0dOOuW5n44LKun iaocvPGpnoHqCDELUIoxUELfTVTcQNRtpNdnB/bVVYEqTc1ruCQ7oSmWug59KGEeRvNPNbE+QOa7r QaysseIQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1onxiQ-0001w3-FN; Thu, 27 Oct 2022 07:54:14 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 484B3300322; Thu, 27 Oct 2022 09:54:09 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0C46A2012B90F; Thu, 27 Oct 2022 09:54:09 +0200 (CEST) Date: Thu, 27 Oct 2022 09:54:08 +0200 From: Peter Zijlstra To: Yajun Deng Cc: mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/fair: Remove max_vruntime() and min_vruntime() Message-ID: References: <20221027015351.2511149-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221027015351.2511149-1-yajun.deng@linux.dev> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Thu, Oct 27, 2022 at 09:53:51AM +0800, Yajun Deng wrote: > There is no need to write max_vruntime() and min_vruntime() functions, > we can use max_t() and min_t() instead. Here; I did your homework for you: /* max.c */ #include #include #include typedef unsigned long long u64; typedef unsigned long long s64; static u64 max_vruntime(u64 max_vruntime, u64 vruntime) { s64 delta = (s64)(vruntime - max_vruntime); if (delta > 0) max_vruntime = vruntime; return max_vruntime; } static u64 max(u64 a, u64 b) { return a > b ? a : b; } int main(int argc, char **argv) { u64 a, b; if (argc < 3) return 0; a = strtoll(argv[1], NULL, 10); b = strtoll(argv[2], NULL, 10); printf(" max(%lu, %lu) = %lu\n", a, b, max(a,b)); printf("max_vruntime(%lu, %lu) = %lu\n", a, b, max_vruntime(a,b)); return 0; } $ ./max -1 0 max(18446744073709551615, 0) = 18446744073709551615 max_vruntime(18446744073709551615, 0) = 0