Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1018840iob; Fri, 13 May 2022 19:50:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzP88wi+hfiXo1NvQPk8CezPlZ7PyBvDpnTMqO7zUyTvHoWrbYa5q29ejw0Q12fr+sOAw3q X-Received: by 2002:a05:600c:4ed1:b0:394:8352:3ea1 with SMTP id g17-20020a05600c4ed100b0039483523ea1mr6839432wmq.153.1652496656676; Fri, 13 May 2022 19:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652496656; cv=none; d=google.com; s=arc-20160816; b=g0BZBUZgRZeemVch0HtV8VjkhOqbZvYr8DHELTknkGCNXBMgrIwU6Yjy+IQEDxTHR7 tfpmMkjnf8QSk1+532vn5p9EgIMBi3OICc8eBPVoeRJPE4jH7RaKYk5UrpRPgC0aGXpL Rip2lA5s/xSnbPER50EmxOxynuNYMFpytjg/b6dKDVDal3Wa5tlta2yHaS8VnJMLT0LW 2lamr7Ir5w2NLOkHqYkLC2Uh0fLPtoP4UYPxqeaWc4nQGFI08GXZlTHLVQWWJYhMRcG4 bIKFWE7TrJgWVQ7PpMAy0XPkyzvR0eJucOhqH3LjhqBo/4F9JUTNgcE2UBcX0hv3kyYi AJVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=FWh5voNwfq9f8ze4W8EiAA/VmAftNIz0jWEqlO9z5kc=; b=RWXFPmChEHqOn0Uc52zR6det3vxSkIQmVjfiobqDyxrJgwPL5Y6ySpiYQ/RnrZO30v wR9Wxs3rmtKQnT6ZSSKlUywqtYdnirRyK5ma4VPvcSMz2WBlJHPi0hZmwVdQoEbU0LhZ 2zoZcfMH7fBBJjU3bGcCey/nuPr+yrh7nV0i6IUDl2A7Cd8XA267iQU25PgxIvCnnQ2Q 6LT12+aNgVqQ3Svlbzuj06bdi0lsoP5IkY/b4f1fBSLK++ALlbs1SVkRg3CdfGOPY9E6 oiVzZchJdGNlP1haxIvMboia24gbT7DpZ/Q76Qy06XAyJvAG8hePa+1Jaaok+Kj7/jO1 jebg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p7-20020a05600c418700b003947deb168dsi6084417wmh.165.2022.05.13.19.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:50:56 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 741B8376D86; Fri, 13 May 2022 16:37:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376440AbiEMCEi (ORCPT + 99 others); Thu, 12 May 2022 22:04:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiEMCEh (ORCPT ); Thu, 12 May 2022 22:04:37 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CEAFD28B84D; Thu, 12 May 2022 19:04:35 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 871701E80C82; Fri, 13 May 2022 09:58:54 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wm2H41FLJxlA; Fri, 13 May 2022 09:58:51 +0800 (CST) Received: from [172.30.21.106] (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 007621E80C80; Fri, 13 May 2022 09:58:50 +0800 (CST) Subject: Re: [PATCH 1/2] kernel/bpf: change "char *" string form to "char []" To: Daniel Borkmann , Martin KaFai Lau , Song Liu Cc: Yonghong Song , Andrii Nakryiko , Alexei Starovoitov , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, hukun@nfschina.com, qixu@nfschina.com, yuzhe@nfschina.com, renyu@nfschina.com References: <20220512142814.26705-1-liqiong@nfschina.com> <223f19c0-70a7-3b1f-6166-22d494b62b6e@nfschina.com> <92cc4844-5815-c3b0-63be-2e54dc36e1d9@iogearbox.net> From: liqiong Message-ID: <6af0b0fe-daf3-5310-2f13-e411a80bdde8@nfschina.com> Date: Fri, 13 May 2022 10:04:30 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <92cc4844-5815-c3b0-63be-2e54dc36e1d9@iogearbox.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 在 2022年05月13日 04:59, Daniel Borkmann 写道: > On 5/12/22 7:08 PM, liqiong wrote: >> 在 2022年05月12日 23:16, Yonghong Song 写道: >>> >>> On 5/12/22 7:28 AM, liqiong wrote: >>>> The string form of "char []" declares a single variable. It is better >>>> than "char *" which creates two variables. >>> >>> Could you explain in details about why it is better in generated codes? >>> It is not clear to me why your patch is better than the original code. >> >> The string form of "char *" creates two variables in the final assembly output, >> a static string, and a char pointer to the static string. Use "objdump -S -D *.o", >> can find out the static string occurring at "Contents of section .rodata". > > There are ~360 instances of this type in the tree from a quick grep, do you > plan to convert all them ? Hi daniel, I have fixed all the string form in kernel tree, summited two patches. Have searched the kernel tree by "grep -nHre char.*\*.*=.*\"", and checked all the "char *foo = "bar" " string form, only five instances are needed to fix in bpf direcotry (2 files) and trace directory (2 files). In most cases, need a char pointer anyway, just like this: [const] char *foo = "bar"; if (xxx) foo = "blash"; In this situation, can't change "char *foo" to "char foo[]". This work was published in "KernelJanitors/Todo". So, I fixed. Thanks. > > Thanks, > Daniel