Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8596125rwr; Thu, 11 May 2023 03:43:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5df7hfNrUqKTAJtNF3WNufYJCDq0w+9YFF0/jE+jVM3P0ds493xemXVbbssxiXCwvoDB3g X-Received: by 2002:a17:90a:134a:b0:252:935b:cbde with SMTP id y10-20020a17090a134a00b00252935bcbdemr1191256pjf.19.1683801814307; Thu, 11 May 2023 03:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683801814; cv=none; d=google.com; s=arc-20160816; b=NH15OEV2HHXqVluAvHgK2Y46rn6nDLFcOo1qR51sWu3gwAwfEIfwqALiFniZq/XOA5 z95MVpf/WiOq+sTFdB+wyY92msE8ni8Xu5jLUQFsW3yqSyuw1u6le7113qGvQhD+/ViU Uzv/WeZ0ZVuImb2ewExK/IR0B9sjIGzoekGa1cRHwO1NI604QVizkNJorgp4L4Z/S06/ r6/kGnupF0sJVlPsczMYwUAXqiddWINvI0a/bQTfbhm77gbYn3eeEfZWV7N5l52aOPTW 4zogAXuZnFO6X+hZI4pCGtHkBSiSNSD9rsfKLo30VFARGGvUTAw9JvqLIXb43JzVRwRb 6sTg== 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=jxXL4psUuIg9EP6KQcn4NIN+LS3QVgwl8WKxbrCWcC8=; b=q0mRtHg4d/BEcTD1FCtW5Te/upw6dfDL3purUh8VrzEn9mjDGLZOBGv0it2r1J/ZMf 4l74hvC0fX+1pM6CQXFsxw1RIEdjK1JLENDxHkPApdl+LZ2gA0UloL6OFLjvNY8f0LNF 4+vgI7PYNbyACZKzHXi7u4xVrLejXR03O9cI3tWhoQIVNNQQfVbLm2RyvHgDyTXK8LVL iEN2BwAN4AAH4XVCkhUwXiNPQ+UT8TemSdDO/FSO5Hhmd8L1YrBJytvukrMKxTQg1G3U OGja4Inth27Oy6rj5Y39NLO0ImszjEoccpPT6Fzm1Y7rTSw2eBe6jT8TWEkpGw/Qg/3k jHTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=ApqH0Cww; 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 b1-20020a17090a7ac100b0024e46c3c2cbsi19734230pjl.50.2023.05.11.03.43.18; Thu, 11 May 2023 03:43:34 -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=@xen0n.name header.s=mail header.b=ApqH0Cww; 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 S237727AbjEKKHi (ORCPT + 99 others); Thu, 11 May 2023 06:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237549AbjEKKHe (ORCPT ); Thu, 11 May 2023 06:07:34 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74A35A1; Thu, 11 May 2023 03:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1683799650; bh=VqDgL7HU+yu2cg9LzMt1GR3g7Ypf89l9GP5PH/EG4Zk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ApqH0CwwldgFtdmJItmpSyedxMCa3vdCBBm1hLHAx7rb9nb90/4I4cvWSP/Nzvdic RHn1nQZ70lRpD5Hrlx+MpgfGDbhrsk8SCxsJPMPylE6stTj9TDWmjWcZg7snb4OC3H ZfLVCSSArHDsVRRb5dReCKL0FPZZ1//ebSGRWyJM= Received: from [100.100.57.122] (unknown [58.34.185.106]) (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) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id B758360106; Thu, 11 May 2023 18:07:29 +0800 (CST) Message-ID: <160f2a29-e935-143a-cdae-7b3e1f2797f9@xen0n.name> Date: Thu, 11 May 2023 18:07:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v2] LoongArch: Add jump-label implementation Content-Language: en-US To: Peter Zijlstra , Youling Tang Cc: Huacai Chen , Jonathan Corbet , Josh Poimboeuf , Jason Baron , Zhangjin Wu , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev References: <1683710206-23905-1-git-send-email-tangyouling@loongson.cn> <3b360532-6ad5-b22c-b02a-103be491be4c@xen0n.name> <72b6c81a-d4ee-575a-ff48-6be7e034ac96@loongson.cn> <20230511074359.GQ4253@hirez.programming.kicks-ass.net> From: WANG Xuerui In-Reply-To: <20230511074359.GQ4253@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 2023/5/11 15:43, Peter Zijlstra wrote: > On Thu, May 11, 2023 at 09:33:37AM +0800, Youling Tang wrote: > >>>> +void arch_jump_label_transform(struct jump_entry *entry, >>>> + enum jump_label_type type) >>>> +{ >>>> + void *addr = (void *)jump_entry_code(entry); >>>> + u32 insn; >>>> + >>>> + if (type == JUMP_LABEL_JMP) >>> >>> Please use a switch for dealing with enum-typed values. >> >> Because the current type only has JUMP_LABEL_NOP and JUMP_LABEL_JMP, >> using if may be simpler than switch. > > IIRC we used an enum with descriptive names instead of a boolean because > true/false just doesn't tell you much. > > The whole thing fundamentally is a boolean descision though, either > you write a JMP or a NOP, jump-labels don't have more options. Ah thanks for the background. My previous suggestion is just kinda generally applicable software engineering best practice, so if the actual enum is unlikely to get >2 variants then it should be fine to keep using "if". Youling, feel free to ignore the piece of comment, and sorry for not doing my archaeology beforehand. :) -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/