Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp767751imw; Thu, 14 Jul 2022 10:22:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uv1Yqtog+H3+DlcxgDP3eqrNyhW7XpKRn3MljKfhd6zKbgUu2xDrTon0ZhKXqT0MrhnuIg X-Received: by 2002:a17:902:8f89:b0:168:d336:ddba with SMTP id z9-20020a1709028f8900b00168d336ddbamr9065126plo.1.1657819371426; Thu, 14 Jul 2022 10:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657819371; cv=none; d=google.com; s=arc-20160816; b=SY66tlJQppiKaRSoBZqxe/J+kdiQ8vNC0J3d+PPuu3CAgWmmibuXxZCotbR/K7zaWK 3IPtju7WvuQxNadBFwWEvFbnB3I2bSIQcDgWfy6Cfjqa/SpudF39x/lBdJhsL5IqJ7dP vy4d8UrBA9TujB01HjqdNbZXvUaMBPpx2RxYkzffZ4CI5wYS54ZSE7X6zbxVXDm702oS qL6MiTDK20DZhLwmgP8ZhKp7W023uVWTWqdG2hoyoFvkCegjWuhR7OWVHh1BGHFWNkfX PTf8+Cler3q1D4VFfynHUm/2vaMn16bvRi9jcu2VvFQmA+QRqo3HcnehS8NiD+9ukCSA Yb6w== 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:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=HjWNjW2j61ucjIjN1Yf39Thjioq1zyAsNONdyKe2ob0=; b=QDAsHwPRjl3S4E2WDbMWLzkm3k5qwl7Lv/Y9SkICqZsgP80SlokdSCgyhGLVYSF7Cc 45arclpk0sRDOmDb2rmfnNG0nVeS/r9ZCM8c7eeKw1GqMQ5WgIlh98YEoREnIRgUMpJa M2x+kGW5JVCdXJlePtGSx7HLrziW0LhkKL3lxVUkauTPSUixKVSfPok6VZZQ2iG2JF/M iaERuJpVcFh3hciEhhdFgnVpNPuEYZ/xjJjx1Q4iGyL3dtZJG56C6AAYO89w0rZi6rSG UFeg9OocsG+vY/0bQ3qDpNW647drrKVA0kpjA00JxIwxkrsvsJqEnrvmnnvMgne/VYie TzeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NfJmaqUO; 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 5-20020a631045000000b004196d075506si2696255pgq.534.2022.07.14.10.22.36; Thu, 14 Jul 2022 10:22:51 -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=NfJmaqUO; 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 S240403AbiGNRML (ORCPT + 99 others); Thu, 14 Jul 2022 13:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232592AbiGNRMJ (ORCPT ); Thu, 14 Jul 2022 13:12:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9CE9F4BD28 for ; Thu, 14 Jul 2022 10:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657818727; 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=HjWNjW2j61ucjIjN1Yf39Thjioq1zyAsNONdyKe2ob0=; b=NfJmaqUOF/VyVcxoJGzXGNSm0Rdg5u0Lcpn64hGrUjt6ioJZ25FE/2fEHIywIjXKg4We8u muwh3gYGoyfiTiT2X6ZTTnW99RniZM0DuVwp93L4CWqCFNNqIMMmxrEh6TxQ2UIjN6m6MG FzQNw3A8AtyznPehVER4UlpJP32ZSxM= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-sBOVOQ2FPhm1bOiUZXe3jQ-1; Thu, 14 Jul 2022 13:12:06 -0400 X-MC-Unique: sBOVOQ2FPhm1bOiUZXe3jQ-1 Received: by mail-ej1-f71.google.com with SMTP id qw8-20020a1709066a0800b0072abb95c0caso963801ejc.15 for ; Thu, 14 Jul 2022 10:12:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:subject:in-reply-to :content-transfer-encoding; bh=HjWNjW2j61ucjIjN1Yf39Thjioq1zyAsNONdyKe2ob0=; b=2PX90YjnFqdQD/9I8QMzzsOzZGTCLeY5UuNeml07rJp+0Jnf3UcOBjX/r1tXzMXGMj 2Y4+msRgrAc+wT+WMknsJeqMzrhLOo2xziaxSJdjGb9g7M1toDanfloIiYwtax+VwUgt WBjA5AbShvYr2jz9mmfS4ugmGX3vlP6QC2NTFMkfxzSEGPFYOVbwSkNGkCyFCBRYIo98 vBAl/a5dGeKSYUAfpsv3ICkh8VYRLcMdI9vRc6/4itWtYL5kK5WFNeD0w8CExfXqE0ah 0mGPfh7hssqx+HeYqtj/z+DtlddurqxATHheZih0LTKKt3k1TzWWl1RIA+V4hnXOs5el 6Tnw== X-Gm-Message-State: AJIora+9HLKwmPzkkzyNczsCpjQcrTk23fz1DvffhX0nKMy+21jvvybO KQAGjpnBkWLmKVDNPvvmNTveszvROo52joo/yrupIOu69kQ1/CamF+Nrx39axr2HVXyG2vWQ1uD d/7Ve15xCXkP71O8KGunQ+IXH X-Received: by 2002:a17:906:98c8:b0:72b:41dc:c271 with SMTP id zd8-20020a17090698c800b0072b41dcc271mr9951335ejb.36.1657818725039; Thu, 14 Jul 2022 10:12:05 -0700 (PDT) X-Received: by 2002:a17:906:98c8:b0:72b:41dc:c271 with SMTP id zd8-20020a17090698c800b0072b41dcc271mr9951310ejb.36.1657818724813; Thu, 14 Jul 2022 10:12:04 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id n6-20020aa7c786000000b0043787ad7cfasm1362571eds.22.2022.07.14.10.12.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Jul 2022 10:12:04 -0700 (PDT) Message-ID: <19b6f502-94f2-621a-4c30-fe9641474669@redhat.com> Date: Thu, 14 Jul 2022 19:12:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Content-Language: en-US To: Linus Torvalds , Boris Petkov Cc: Guenter Roeck , Peter Zijlstra , Thadeu Lima de Souza Cascardo , Greg Kroah-Hartman , Naresh Kamboju , Florian Fainelli , kvm list , Andrew Morton , Dave Hansen , stable , Linux Kernel Mailing List , Pavel Machek , Jon Hunter , Sudip Mukherjee , Slade Watkins , patches@kernelci.org, Sean Christopherson , Shuah Khan , Ingo Molnar , Thomas Gleixner , X86 ML , lkft-triage@lists.linaro.org, =?UTF-8?Q?Alex_Benn=c3=a9e?= , "H. Peter Anvin" , Anders Roxell References: <20220712183238.844813653@linuxfoundation.org> <6b4337f4-d1de-7ba3-14e8-3ad0f9b18788@redhat.com> <8BEC3365-FC09-46C5-8211-518657C0308E@alien8.de> From: Paolo Bonzini Subject: Re: [PATCH 5.15 00/78] 5.15.55-rc1 review In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 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,SPF_HELO_NONE,SPF_NONE,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 7/14/22 19:02, Linus Torvalds wrote: > And guess what? The code could just use roundup_pow_of_two(), which is > designed exactly like ilog2() to be used for compile-time constant > values. > > So the code should just use > > #define FASTOP_SIZE roundup_pow_of_two(FASTOP_LENGTH) > > and be a lot more legible, wouldn't it? > > Because I don't think there is anything magical about the length > "8/16/32". It's purely "aligned and big enough to contain > FASTOP_LENGTH". roundup_pow_of_two unfortunately is not enough for stringizing FASTOP_SIZE into an asm statement. :( #define __FOP_FUNC(name) \ ".align " __stringify(FASTOP_SIZE) " \n\t" \ ".type " name ", @function \n\t" \ name ":\n\t" \ ASM_ENDBR The shifts are what we came up with for the SETCC thunks when ENDBR and SLS made them grew beyond 4 bytes; Peter's patch is reusing the trick for the fastop thunks. > Because I don't think there is anything magical about the length > "8/16/32". It's purely "aligned and big enough to contain > FASTOP_LENGTH". I agree with that, it's only limited to 8/16/32 to keep the macro to a decent size. > And then the point of that > > static_assert(FASTOP_LENGTH <= FASTOP_SIZE); > > just goes away, because there are no subtle math issues there any more. > > In fact, the remaining question is just "where did the 7 come from" in > > #define FASTOP_LENGTH (7 + ENDBR_INSN_SIZE + RET_LENGTH) The 7 is an upper limit to the length of the code between endbr and ret. There's no particular reason to limit to 7, but it allows using an alignment of 8 in the smallest case (no thunks, no SLS, no endbr) where you just have ".align 8; ...; ret". Paolo