Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp235388pxb; Wed, 23 Mar 2022 17:08:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwx++QMJ0i04dXxkCcyzNVobS+wLLpZTQmfDs2ggeDP2/0jm8G7eB/e0vJ6j5soU7fiW/+6 X-Received: by 2002:a50:ec0c:0:b0:418:f415:6bfe with SMTP id g12-20020a50ec0c000000b00418f4156bfemr3473883edr.15.1648080522244; Wed, 23 Mar 2022 17:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648080522; cv=none; d=google.com; s=arc-20160816; b=W1VRVzLYlMOZ0GUcqnqv+KGmLctdvSoM4LAkodtJogpbm233bXXPm9dskdpw/9yfGI F9FWGT4u506tlcK3JTPofI6MtSRuW/0yTP6AnV5gQGtloflJDrvsSdHLsw22kGOSiBwz t8jJqMtLhzw4N+/RJGp1BibROo5L3ss2i1ow0xvsvtCxt9zRI//wSKh/+Clquj009nDS GZE7Q0eNP+//O90AZNY7mD5b6zoZ0Dc4GGg3anJNnYKr7SRgKcEqT1xihYDez6s51ZAN jOk1wQpqpRYxwfTxrktWJ1NlIr6nTWT0auTwUl0qa/0fHcTPSAAv6WCEfMNiWwgRN2s6 PmQQ== 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; bh=N1gienBbh/eLpEd+/D5dBjxykyl5yxoqjYn5LAMc7zs=; b=MSaI/X7DQ3wvc8WEUL626aWThFodex67YjT75RYgO8/0ucP7pTUtXwIXBEENxHljO9 7spvQG+q/cQJAy8LPQM7N5MVIfofpCRCLWH8OK+QIKUVZcfq3uJSYZABsXjtAD0k0gzs 3VD3X3da9eSq9GJ7FP0mXJHL+nYPYKDCKeGTuTO1hgv/p2MVK3rF+8DznJE3R6pI5xcw 1k+4pqnSjewdsPLCVZhIfAMt91LeSDPMKA9sTBwXlyW4NHXrUTv67Yuo/Cr1T+8KoFFL xQFYcuVi39tJDvLmD5lgkA32iqpRrC/4LXWiBk4gV302lJSsdZEMZS3Z8uzb43m6YBLY F09A== ARC-Authentication-Results: i=1; mx.google.com; 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 u16-20020a170906c41000b006df76385e04si13120797ejz.676.2022.03.23.17.08.16; Wed, 23 Mar 2022 17:08:42 -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; 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 S230159AbiCVVDs (ORCPT + 99 others); Tue, 22 Mar 2022 17:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234990AbiCVVDl (ORCPT ); Tue, 22 Mar 2022 17:03:41 -0400 Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B391254BC8; Tue, 22 Mar 2022 14:02:10 -0700 (PDT) Received: from [192.168.0.3] (ip5f5ae922.dynamic.kabel-deutschland.de [95.90.233.34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 4387161EA1928; Tue, 22 Mar 2022 22:02:07 +0100 (CET) Message-ID: <68ccb162-459b-cb95-19cf-3e0335e4c981@molgen.mpg.de> Date: Tue, 22 Mar 2022 22:02:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Don't do arithmetic on anything smaller than 'int' (was: [PATCH v2] ice: use min_t() to make code cleaner in ice_gnss) Content-Language: en-US To: Jakub Kicinski , David Laight Cc: Wan Jiabing , intel-wired-lan@lists.osuosl.org, LKML , netdev@vger.kernel.org, Paolo Abeni , "David S. Miller" References: <20220321135947.378250-1-wanjiabing@vivo.com> <20220322175038.2691665-1-alexandr.lobakin@intel.com> <20220322112730.482d674d@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Paul Menzel In-Reply-To: <20220322112730.482d674d@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,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 Dear Linux folks, Am 22.03.22 um 19:27 schrieb Jakub Kicinski: > On Tue, 22 Mar 2022 18:12:08 +0000 David Laight wrote: >>>> Oh FFS why is that u16? >>>> Don't do arithmetic on anything smaller than 'int' >>> >>> Any reasoning? I don't say it's good or bad, just want to hear your >>> arguments (disasms, perf and object code measurements) etc. >> >> Look at the object code on anything except x86. >> The compiler has to add instruction to mask the value >> (which is in a full sized register) down to 16 bits >> after every arithmetic operation. > > Isn't it also slower on some modern x86 CPUs? > I could have sworn someone mentioned that in the past. I know of Scott’s article *Small Integers: Big Penalty* from 2012 [1]. Kind regards, Paul [1]: https://notabs.org/coding/smallIntsBigPenalty.htm > _______________________________________________ > Intel-wired-lan mailing list > Intel-wired-lan@osuosl.org > https://lists.osuosl.org/mailman/listinfo/intel-wired-lan