From patchwork Tue Feb 21 20:55:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 60239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp217243wrd; Tue, 21 Feb 2023 12:54:37 -0800 (PST) X-Google-Smtp-Source: AK7set/mStehqN8ChWHzJtNueNo1/i2pxu6/USyRewC4KXD3fwJ+sndFPgGvIbbKc3EPrcCu/m8q X-Received: by 2002:a17:902:cec1:b0:199:2f0a:697 with SMTP id d1-20020a170902cec100b001992f0a0697mr9466940plg.33.1677012877054; Tue, 21 Feb 2023 12:54:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677012877; cv=none; d=google.com; s=arc-20160816; b=IlKQq0ofDAUIAh57K0M6LuI8Hwrv3UNM9VxX87T+lO3t0UKJbugyY5AgnPvtUX4c3b +aXBqA+3XDXOKwsTjQ2KGJr7pY4pMlzkZLYnQ5MfNA1cn4KDWXf20g3EmkWONmeHS7yV oTIkJ0uL3zoK0RXiCq7xV2EJGqoUhL9pafGY+G3P/ss0gSqb1CwM3AEldXPvu2iMEiCp lznoERZDjnqSRzJYpYPZi99Epdc1S04qi6r5u82WPdgMH13rmvDiskrRdSnL2M/akAaw 7YrdPGJNzp111KoVKHSWsd20Hwt9GzhxNCqWVq22gEuTCKivVh5kgNomTSbWjYhiaASh 1FIQ== 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:cc :references:to:from:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ysPH6WPpk5eU7Ka5J53d3h1W3zWHMXnSdV9y5Xs+C1E=; b=fhOAn955DgLkggYMCuSpP/Ts0W9rXteVHQC80qDYtDODsenbpmHP4uypMi+Em08BQN AqA9Cx4Hm0BYYF/xHjHtPi81CbHzDchig7G37u5AF/oq3DoH9d1ctU2IeLJEcKox7pgt h+Jrz4qPY2D4yXm8fpHE00bgXUKkKZlpBfhZ+rm8O+x2KZRLFtCHHF1mbdpXT85dztm7 X95RANsR/4KSpP7FvJxkGTSJ6+n0ap5MTbSyJGC/RDXHynLPP+EjmLeKzU6W6620lgyZ xFdrAn12g6NM07UPuBTRgnPctD4fKbw7YBkINqMQeiLx+bHKfhU87akBz3a4bt14qzUD xuog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=Nn9ZobLL; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a17090322cf00b001967580f630si15666188plg.133.2023.02.21.12.54.21; Tue, 21 Feb 2023 12:54:37 -0800 (PST) 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=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=Nn9ZobLL; 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 S230039AbjBUUlv (ORCPT + 99 others); Tue, 21 Feb 2023 15:41:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbjBUUlu (ORCPT ); Tue, 21 Feb 2023 15:41:50 -0500 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 332612D142 for ; Tue, 21 Feb 2023 12:41:49 -0800 (PST) Received: by mail-il1-x135.google.com with SMTP id c4so2428262ilr.13 for ; Tue, 21 Feb 2023 12:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ysPH6WPpk5eU7Ka5J53d3h1W3zWHMXnSdV9y5Xs+C1E=; b=Nn9ZobLLbydXkfGjLJB+NFQlDhB969riVbUYWeDqDKElp4mXynQXXexrDy0ffT6YK4 LoGUUYX6NNlTl09hrodIvLY7GmBIcceWjNAegEsFvcRev8u078caDhxO38Fv/L+i8x2/ JxMK4Ejurbuu4JhDBKiHZwSf4SKsIORadTEsSRqgcjnMpdGc6Q/Jjy7qM6nM/Ysw9EuK qOOffUrokZsXg1SCsJ2XJoEfb3S1VJMvYvU5Nc60od4WmEBrUaleGdLosuUbv8ubAj4o yViwXi1+ssBG1sK8rmQ7/bbhoULipaDOkKvjSi4bVuiwjkgjVMNqJN6SmEmclDiUuHCq AV6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ysPH6WPpk5eU7Ka5J53d3h1W3zWHMXnSdV9y5Xs+C1E=; b=qBbqqF2BHKV6/ecYtK6/eHR/mZGQ5nhZpwl5UtlgqmMiXbiGypd/82OO4/yGLEUYyJ c6pt6Vxbs9Am2m6Nwan9gUtL0kebuKcuS9S564s754pgGnAxk+eb+XNG4Y6g0vsGUTMg +snQUidjLcZ4scKSRBBt5zfFQagN39ufCaXtwf1cR3abJZUaClyGTO6aTEKOIMY8lEqZ Zss2MZP6pxFEZnAesQrRPLHV4UPwFWei3CtZpB5kO8EysSOJ2msuMrBD8J834OS5ANDt vaPAITgdUb/k1uOq3yv2EJMI1/9miDN6jzXRGtdbHd46nLIF1wBkDMqxf95mlYipOFnP lpXg== X-Gm-Message-State: AO0yUKV1aL5zL0+dNNRLrxru+EkbnjAY6b0zrAi24nYXRHoRTC43z2It JMmK4ST3RmVOXmTIP9FK/kw+x8t8K8ZpgxCK5M8= X-Received: by 2002:a05:6e02:20e7:b0:316:d9fa:f4fe with SMTP id q7-20020a056e0220e700b00316d9faf4femr3001680ilv.24.1677012108470; Tue, 21 Feb 2023 12:41:48 -0800 (PST) Received: from [172.16.32.78] ([198.232.126.202]) by smtp.gmail.com with ESMTPSA id d14-20020a02a48e000000b00375783003fcsm6303jam.136.2023.02.21.12.41.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Feb 2023 12:41:48 -0800 (PST) Message-ID: <63c2936e-6bc7-67e3-eaf3-0123333381f8@landley.net> Date: Tue, 21 Feb 2023 14:55:10 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH 1/5] try generic compiler name "cc" before falling back to "gcc". Content-Language: en-US From: Rob Landley To: "linux-kernel@vger.kernel.org" References: Cc: Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Tom Rix , linux-kbuild@vger.kernel.org, llvm@lists.linux.dev In-Reply-To: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,URI_DOTEDU autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758475454643226597?= X-GMAIL-MSGID: =?utf-8?q?1758475454643226597?= Distros like debian install the generic "cc" name for both gcc and clang, and the plumbing already does CC_VERSION_TEXT to include Makefile.clang. Previously: https://lkml.iu.edu/hypermail/linux/kernel/2202.0/01505.html Signed-off-by: Rob Landley --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3f6628780eb2..0ac57ae3b45f 100644 --- a/Makefile +++ b/Makefile @@ -456,7 +456,7 @@ endif HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX) HOSTCXX = $(LLVM_PREFIX)clang++$(LLVM_SUFFIX) else -HOSTCC = gcc +HOSTCC := $(shell cc --version >/dev/null 2>&1 && echo cc || echo gcc) HOSTCXX = g++ endif HOSTRUSTC = rustc @@ -503,7 +503,8 @@ OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX) READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX) STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX) else -CC = $(CROSS_COMPILE)gcc +CC := $(CROSS_COMPILE)$(shell $(CROSS_COMPILE)cc --version \ + >/dev/null 2>&1 && echo cc || echo gcc) LD = $(CROSS_COMPILE)ld AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm From patchwork Tue Feb 21 20:56:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 60240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp217309wrd; Tue, 21 Feb 2023 12:54:50 -0800 (PST) X-Google-Smtp-Source: AK7set/FRTopI+firXwVlpihwg3TbIAP6VyIv0R7BfdlRmxN89obVnVEA0LlQBTEOTV0UR6s9cUm X-Received: by 2002:a17:906:ce47:b0:878:6b39:6d2a with SMTP id se7-20020a170906ce4700b008786b396d2amr16768061ejb.46.1677012889891; Tue, 21 Feb 2023 12:54:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677012889; cv=none; d=google.com; s=arc-20160816; b=kfMlZffTLePl7wE7KzTlInDTtackJcif0SnG+6tV425b9tbdJhCDkZTBpHC457VCTp 6Tv0zZS11LUCLDOACO9eSueA2t/NjC/qE5nrO1E3AbDR9YFpkcOgYKIzBn1CnJyIDgck A2y5ooIr2bVYER+QtK/S8+IUzqnHHxw+ExYxBhhL7ICrHLNweffa/VwHBGrtXBT+WzYq lOHa+jLvwJem6vscNlXULV6BMKCS7q+ZhbB7Clt/Ml1rZRs4D8XSIQypPLs3X9Fvx3c1 gRPHZmsZ1SjRMoOOb9PIv+Xrzcj/YIY7dsoc3jwPdB9yoDGBB2pf1/m8hDrpMJyebU3e SPkQ== 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:cc :references:to:from:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=vm75klYCEzEbHDHndrCCa53U4DXnX5iMoTt+cEU3S0k=; b=T+smm+941KmFH2o0eGZxHkCnRlh2nX/J3Bi8SJXHrHRNElL5uzRCoHAoJpwz9pJV5O rDyea6hSyIiPRtHJuqlw3kCvVOJuNtStqp+Pqign7NdDstdY5Bmyzhx51nBZntIeWpLb i89AlFtYpiaOULWsaKJ7ARRt7pW6VvHqTDGpgr+qcZu4voRm/sc+NnSaToSNZ2o6lPsI xHTqU8uLTeyTSf2Bu6qP92SRveuN1CUgLc0Rgrt90ivOWh9NUn5aZkath+XD1EswzTEb G2Ao2LSgIzTMNxVrJqYefJqA91ljUjMy9lxko3pKy9goepMSgZgT5BGMbJIpcEZwf6RH KNXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=2NS3OR2p; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fm19-20020a1709072ad300b008de4a641fe9si3579123ejc.659.2023.02.21.12.54.26; Tue, 21 Feb 2023 12:54:49 -0800 (PST) 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=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=2NS3OR2p; 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 S229552AbjBUUnF (ORCPT + 99 others); Tue, 21 Feb 2023 15:43:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjBUUnE (ORCPT ); Tue, 21 Feb 2023 15:43:04 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34982902C for ; Tue, 21 Feb 2023 12:43:01 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id e9so2442922ile.8 for ; Tue, 21 Feb 2023 12:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=vm75klYCEzEbHDHndrCCa53U4DXnX5iMoTt+cEU3S0k=; b=2NS3OR2pHewL7snzecmtNkKql2ldQjPzSlRQ492qlYpP3HVihZQxhtknTitHhGpSPp Vg52n9qaS1s1VyIPF0N2gMGATTKkUf23t6apX4QaDB+hHfuu2dEomMXJ9mNJaOEc/lFD f6JAunLj3KSPRrUt9bzYImyTqJjpRfuZtGWQasHgrTRYamZukniq7Klfm0PpgdBt9r3M vI2usPLjKsuGahkHtKG0aRwx26YHOfQ3j3reWufaWNN2MGRJVbgOlcZjt9CCRsEeFEsv 53B6Pw/hW53Gk/SQegxqTDYON/vjCatV7lIlWDkRYWqCc6dvtTWtcWLA70hQBEMDzr5k TiiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vm75klYCEzEbHDHndrCCa53U4DXnX5iMoTt+cEU3S0k=; b=jCDHuxLU/srplZeL0Bd1uVKE1IHJgi4SorSnlFBTSlCjrRugp4Mu4AdsXntobOHvNT 7Knd1mRkICKSjSvGz7QmjDSqxV9IWiB1ws/hvc4qQDkFaqyS/jbkuCqvN8Krh1KZELJ3 PDeva0ABalhPFQ8ZxJPXhQHfkB4Vnbmb3ZXuk9mkE6lAxGUqb8xd9Oil7LW0nVlodJly MDxlq4OmXka+rT1AQJwkHSQoFQ0Xhh4VnUXtmz8L7CoQB9BNsTq55uDqDNWZInsjb2DD 8JV2o4L26FozVE4rTB4k/Loz4hztXf1gojK73j2o5OgmB8RVrlMmvpb8cKRjijULSo+w WqVQ== X-Gm-Message-State: AO0yUKXv1cB3PhcIn5s5Po9ckz/pSINI8xvFT8C/UEaMlYt0w++yfM7t Pt+j3sxMcw1HstCCoXpTcfZ2Dy7WeGlnULBQTv0= X-Received: by 2002:a05:6e02:8aa:b0:315:9a7e:fb03 with SMTP id a10-20020a056e0208aa00b003159a7efb03mr3718684ilt.29.1677012180442; Tue, 21 Feb 2023 12:43:00 -0800 (PST) Received: from [172.16.32.78] ([198.232.126.202]) by smtp.gmail.com with ESMTPSA id s11-20020a02ad0b000000b003c5144d10b1sm35125jan.83.2023.02.21.12.42.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Feb 2023 12:43:00 -0800 (PST) Message-ID: Date: Tue, 21 Feb 2023 14:56:22 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH 2/5] X86-64 should not uniquely require a third ELF package to build. Content-Language: en-US From: Rob Landley To: "linux-kernel@vger.kernel.org" References: Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" In-Reply-To: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,URI_DOTEDU autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758475467752598540?= X-GMAIL-MSGID: =?utf-8?q?1758475467752598540?= x86-64 is the only architecture that can't compile without an extra ELF library installed on the host. (The kernel already has multiple ELF parse implementations built-in, so requiring another one is questionable at best.) You can switch it back on in menuconfig if you want to, this just stops it being mandatory. See https://lkml.iu.edu/hypermail/linux/kernel/2110.3/00402.html and https://lkml.iu.edu/hypermail/linux/kernel/2110.3/00278.html Signed-off-by: Rob Landley --- arch/x86/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3604074a878b..b63510d79baf 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -243,7 +243,6 @@ config X86 select HAVE_NOINSTR_HACK if HAVE_OBJTOOL select HAVE_NMI select HAVE_NOINSTR_VALIDATION if HAVE_OBJTOOL - select HAVE_OBJTOOL if X86_64 select HAVE_OPTPROBES select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS From patchwork Tue Feb 21 20:57:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 60244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp217682wrd; Tue, 21 Feb 2023 12:55:56 -0800 (PST) X-Google-Smtp-Source: AK7set+zKnKyNug4yxYyvmnKYms23EfY0S3n/rLi8Ozd3IBe/xfpx4TnOp+Ng3RTVya/ZkMdPrcO X-Received: by 2002:a17:906:aac5:b0:8b1:7a83:1a33 with SMTP id kt5-20020a170906aac500b008b17a831a33mr15099080ejb.54.1677012956221; Tue, 21 Feb 2023 12:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677012956; cv=none; d=google.com; s=arc-20160816; b=gFXUM/WudnG2Xt+n+FqDj6bjrlD2rA3SGkn5ZoRobPXaEAgSiZOAOR7bcStJSUqZiJ 0JkeDuW+Y6r5Pkr9S6cds1tX2OKH4YnUY3xvgfHMiIREP+ansVVxDpH8KgOBSS25TsQa lUX4TlEfsbrx7pNN92jzcwlmC3Mk7htp2l/YEj3FOZVBjA3pxQOpJ/kVVYoEKLzHDwwp mKpunfJ+rTu5M6f0022HJBWl0ZHzrXDvIthryYV0dM28aLlGYXDH2zCmTvfKE/pa+SUJ msIiiy8HCjsWtDcMuU63LokoEWKF0g9YT9jsYAftbrcySnjtE3nFioc/DDp9X9paWsSA ChiA== 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:cc :references:to:from:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=49jaS/AoSPvQMwYGklpLYAUlZviDdzb1WWfRNr+yMgk=; b=P+tb2DK7MyjfBbBZlEm+HTT8aQhiLoYfYhSkaEHfjkTtl1ryXkCrEZTeTFB78iKCjm +kEqix26/Hbxn6tD715di77WobHLRJsOdieSucl0kRncZx6iT1yUMKABHiCi5rVyPIKD QPNnezcDYmlioxXx5dbJwEwmjMdZJYGo2RDhyPtMtM++REEyxLRAhnCaD94iTSVDEi7r NS9jlO6SZpmMr9LgI6x2+BW59Uix9t5nyXhYYqoglKwaBTF2uhYFaFVn3gASzrBvlW6K SoCR6v7U81ZlTbHHUqlgXBi8zF3AJXaIFCgFy338g8eR7YLhCzd2bwehZa5VcMgbITDe p4fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=TiW6dYtn; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j24-20020a170906535800b008b176e0b0c4si19395906ejo.957.2023.02.21.12.55.32; Tue, 21 Feb 2023 12:55:56 -0800 (PST) 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=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=TiW6dYtn; 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 S229557AbjBUUod (ORCPT + 99 others); Tue, 21 Feb 2023 15:44:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjBUUoc (ORCPT ); Tue, 21 Feb 2023 15:44:32 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F1D8DBD2 for ; Tue, 21 Feb 2023 12:44:31 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id 76so2645978iou.9 for ; Tue, 21 Feb 2023 12:44:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=49jaS/AoSPvQMwYGklpLYAUlZviDdzb1WWfRNr+yMgk=; b=TiW6dYtn3K777+JOBrVQT5giuhxe9NEzMr9OlXgXryxTH/e+GodtHhRXpHs6cGuj13 GYNwFVOvFc3XYD0mhC6djWiz4FP2IrJ+ff7pv1EYoo+gvcJIu98SEZRrEPc0I380Z4uu h0f5XpW9dmpOsKofkV20IHDPewuoH9HrykCrvEopHGdJj2xBjIw2YF7r7dsj9X8KaMYZ Bz9e31IwZ1NXgcmICMvoDC8iSf78f5m87hSvXUtaHw5MPndaWCBlx3pB1XhgL3KioyAr g2wbIyDDzBBaZT8QM39vDNL0ikAZLnP6aJqT3EeXtiZTRTpN13UccN7FoYb0eKIT8F34 F/Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=49jaS/AoSPvQMwYGklpLYAUlZviDdzb1WWfRNr+yMgk=; b=HmmUK0mnYp4iZz7H5U5n6kbpiboMiWCjKq8cPq/+mZJjNa2d7fuJDTS5UNVfe/TnQ5 8ITj0BWbgO3DWL+5SqhQXxHZSaO3tT3zXjWJ9jjGoQRQa1XVeIew+jqjtAbFdcIOwcI8 11rDnRI526BqQz3SIYV9P0ang/ABYsqX7ksA7FV3EzxtSlNy21dzSYYEapx4WyUmCKOK Vy5XF7FecHpnrWl4LxPlX2sZs7FTQfcMjpuRjraSd5r5stXRmB+Sa6OwODdjvI5+EbHK PUtypRrtNGpFIYgtmy+dJCc+WBXusBN6X/7HcrsT9HF/H3o6hzK1gokW3g349mUa3Vts Dtwg== X-Gm-Message-State: AO0yUKVO4uvHsDSXLRZqHeNrCIbNDEeIcFp+ssDwB6HJ23SNKk7nu6vI Vr98IKng5+yoaFqYXWZCG2HVEKMZ61PwZzZJSnU= X-Received: by 2002:a5e:da41:0:b0:73a:6d8e:9e34 with SMTP id o1-20020a5eda41000000b0073a6d8e9e34mr4221940iop.1.1677012270750; Tue, 21 Feb 2023 12:44:30 -0800 (PST) Received: from [172.16.32.78] ([198.232.126.202]) by smtp.gmail.com with ESMTPSA id y3-20020a6bc403000000b007407e365832sm728702ioa.23.2023.02.21.12.44.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Feb 2023 12:44:30 -0800 (PST) Message-ID: <749b6e7c-244e-fdfb-b95c-1803678b8bdc@landley.net> Date: Tue, 21 Feb 2023 14:57:52 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH 3/5] Wire up CONFIG_DEVTMPFS_MOUNT to initramfs. Content-Language: en-US From: Rob Landley To: "linux-kernel@vger.kernel.org" References: Cc: Andrew Morton , "Steven Rostedt (Google)" , "Jason A. Donenfeld" , Masami Hiramatsu , Peter Zijlstra , Mark Rutland , Mark-PK Tsai , Alexey Dobriyan , Li Zhe In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758475537782616663?= X-GMAIL-MSGID: =?utf-8?q?1758475537782616663?= The kernel has had CONFIG_DEVTMPFS_MOUNT for years, but it only applied to fallback ROOT= not initramfs/initmpfs. As long as the config option exists, it might as well work. I use this for board bringup: populating a chdir and calling cpio as a normal user often leaves /dev empty (because mknod requires root access), meaning no /dev/console for init/main.c to open, meaning init runs without stdin/stdout/stderr and has to mount devtmpfs and redirect the filehandles blind with no error output if something goes wrong. Signed-off-by: Rob Landley Previously: https://lkml.org/lkml/2017/9/13/651 --- init/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init/main.c b/init/main.c index e1c3911d7c70..eca7ba2c2764 100644 --- a/init/main.c +++ b/init/main.c @@ -1636,7 +1636,6 @@ static noinline void __init kernel_init_freeable(void) kunit_run_all_tests(); wait_for_initramfs(); - console_on_rootfs(); /* * check if there is an early userspace init. If yes, let it do all @@ -1645,7 +1644,11 @@ static noinline void __init kernel_init_freeable(void) if (init_eaccess(ramdisk_execute_command) != 0) { ramdisk_execute_command = NULL; prepare_namespace(); + } else if (IS_ENABLED(CONFIG_DEVTMPFS_MOUNT)) { + init_mkdir("/dev", 0755); + devtmpfs_mount(); } + console_on_rootfs(); /* * Ok, we have completed the initial bootup, and From patchwork Tue Feb 21 21:00:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 60241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp217493wrd; Tue, 21 Feb 2023 12:55:20 -0800 (PST) X-Google-Smtp-Source: AK7set8PVLP5kfJC85caghFbqBrhd2Bf8zsvcSWuzI0rvKXBxDUbHiyDXBopx+5DVDuVFt7EOU+G X-Received: by 2002:a05:6402:454:b0:4ac:be53:1789 with SMTP id p20-20020a056402045400b004acbe531789mr4915458edw.40.1677012920050; Tue, 21 Feb 2023 12:55:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677012920; cv=none; d=google.com; s=arc-20160816; b=MtFApwRcNlAS7Hw99SXhH/+vFaMSTzYtnhfktxlYV8YqscajLpx9ng6xgrWtbk70Tg ckXaq+akxBE/ezWK+WnfiUE0xLSwvfzzSn9DjB2f1yxQqCwIEhINdLRFuftGNBvUObWJ PJ7VyFvaKOw+4w5yey9EAwG3d6ZKt6TMwmRiZFcQRcy4kIBGhgZORnLZLHtjXtYwmI44 6qpOLmrqBujgbxharloojBe2JCyTFXCLmjl2OXvvvAzb8EBWNn1/nOUas3DePN8SCMG9 Qjg++/wBtllz3biQsmfw9xHnWoK9q0+iRNnI1o0NAXZewMGdH+tjyU0dPwlonKUTWrTC eaIw== 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:cc :references:to:from:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=uf0g4olu2xig7H0ri3aToWO9GEhRK/5oEG6kOHqHj/Y=; b=te4fF7pdtIetc7O4FwmU0EEqnh1YaLS5JI4opFJU4eFx3QBOgrBZxEKVZvZfh/3ugJ i40PehKuz5oPJEe+4y8XF3BTvFq2ibBRgBRW/t4+u0rL89m//MMiQnn4U75Q8bsrq0GD rFUJQJMmUnAA9okxbv+aaqLd1AH3JuEWh2VeN2K8NXwhQx1eBLnObqmlKwB4VavKzj3b 0d+n8l4LhJjRbmDK1jzhpEQHtwk4F5WFj4CzJwb4Eg3J1cRM55Owj8WrhAMwxAUMgkKH zgVHTUWqJ/KaDXJ4xoddITnVF9aXdQiqU4+oYsG7TYkBp1Zhb2nLORwJ8FmOain86HKN qViQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b="XS/ubnS5"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r26-20020aa7c15a000000b004a18f2ffb81si1463506edp.321.2023.02.21.12.54.56; Tue, 21 Feb 2023 12:55:20 -0800 (PST) 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=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b="XS/ubnS5"; 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 S229684AbjBUUr2 (ORCPT + 99 others); Tue, 21 Feb 2023 15:47:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjBUUr1 (ORCPT ); Tue, 21 Feb 2023 15:47:27 -0500 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9D3B2E811 for ; Tue, 21 Feb 2023 12:47:25 -0800 (PST) Received: by mail-il1-x133.google.com with SMTP id z3so2421283ilm.0 for ; Tue, 21 Feb 2023 12:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uf0g4olu2xig7H0ri3aToWO9GEhRK/5oEG6kOHqHj/Y=; b=XS/ubnS5zKQD08kJ3z/EGfFnkrgBt3IZR2H9lnj9GPbDHPh6lTtJdiYfA1Az3ZTP+V v7ONqnuVzN/thsi3+pkart7m0Ez+/nQq5A+oZUM6iYBD6shkHjhvnW4rshe2tjHw5Wnh F9bgbJBNMoykBwSC+6EkYfmcl37cl1gPs/IUMX4Xf/w4pp3hNQGDFkYE027d6RVwZAbq 8KK6qJ6fbQD7BY0tHfBHvaRDg44bVVkaxoN/pBI7c5HD0rBP5PI/AX///ldjzieQC3N8 PJTyc/U+GNJnqZlBtQ9ei8Y/CKcaj4+lPljsPv8rRpCT0iGq+wXNZRfesG+kfVgJdtMW MkDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uf0g4olu2xig7H0ri3aToWO9GEhRK/5oEG6kOHqHj/Y=; b=HgVoYykam95EJfs1KgmIsvManigJuvpDu40EIDoc1ye6Ac2sodysDV0Jhp/uCL6btz YYt8xL8RMUmrFff67N/OCTqowy8SanIXUGJjGxg9F1YqkvlplYFWGud/3qw3otCSoi9x BFu8NZkLjJQD/zXYg04Tau9GvsNKjlVWoGJVxz0SfE9jT1LJR4SD/RPkraXIThvwyKSr i8AUANWsn4cvW3JycZNF9nLUSMzM0mtmYUt6sC7AidvMFqNu37Y8L9FoEJhc9e3QgD8x wwh5WRGBOLD4FEaNiS+KSz2/SUeo2qjgEySdfsysr96GTSWV59kf4cqvm8xG9nkOyMTi kYtA== X-Gm-Message-State: AO0yUKUjEUIdxRB9ltrPr8CnglQH2oMNmaFdPZXV1wAslIq6hvjt7u3d 2agUY7kViIKSndVuXvN59k2sW6gP3HdIorzN X-Received: by 2002:a05:6e02:1c21:b0:315:48df:ecde with SMTP id m1-20020a056e021c2100b0031548dfecdemr3289324ilh.8.1677012444799; Tue, 21 Feb 2023 12:47:24 -0800 (PST) Received: from [172.16.32.78] ([198.232.126.202]) by smtp.gmail.com with ESMTPSA id f13-20020a056e0204cd00b00315d1153ffcsm1488477ils.65.2023.02.21.12.47.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Feb 2023 12:47:24 -0800 (PST) Message-ID: <9b8ce4db-9e1b-32b6-f749-94e4decc032e@landley.net> Date: Tue, 21 Feb 2023 15:00:46 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH 4/5] Replace timeconst.bc with mktimeconst.c Content-Language: en-US From: Rob Landley To: "linux-kernel@vger.kernel.org" References: Cc: Masahiro Yamada , Nicolas Schier In-Reply-To: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,URI_DOTEDU autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758475499658121577?= X-GMAIL-MSGID: =?utf-8?q?1758475499658121577?= Update of my decade-old patch replacing timeconst.pl with mktimeconst.c, still removing the only user of "bc" from the build. All that's changed since the 2015 version at: https://github.com/landley/aboriginal/blob/master/sources/patches/linux-noperl-timeconst.patch Is one extra iteration of the loop for nanoseconds and different makefile plumbing calling it. In theory this could calculate the values at runtime in a small _init function and eliminate the header or even allow HZ to change at runtime. See https://lkml.iu.edu/hypermail/linux/kernel/2211.0/02589.html Signed-off-by: Rob Landley --- Kbuild | 7 ++- kernel/time/mktimeconst.c | 111 ++++++++++++++++++++++++++++++++++++ kernel/time/timeconst.bc | 117 -------------------------------------- 3 files changed, 116 insertions(+), 119 deletions(-) create mode 100644 kernel/time/mktimeconst.c delete mode 100644 kernel/time/timeconst.bc diff --git a/Kbuild b/Kbuild index 464b34a08f51..8c12f6ef58c6 100644 --- a/Kbuild +++ b/Kbuild @@ -18,9 +18,12 @@ $(bounds-file): kernel/bounds.s FORCE timeconst-file := include/generated/timeconst.h -filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $< +hostprogs += mktimeconst +mktimeconst-objs = kernel/time/mktimeconst.o -$(timeconst-file): kernel/time/timeconst.bc FORCE +filechk_gentimeconst = $(obj)/mktimeconst $(CONFIG_HZ) - + +$(timeconst-file): $(obj)/mktimeconst FORCE $(call filechk,gentimeconst) # Generate asm-offsets.h diff --git a/kernel/time/mktimeconst.c b/kernel/time/mktimeconst.c new file mode 100644 index 000000000000..c4c0df289472 --- /dev/null +++ b/kernel/time/mktimeconst.c @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: 0BSD +// Copyright 2010-2023 Rob Landley + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + uint64_t hz, periods[] = {1000, 1000000, 1000000000}; + char *names[] = {"MSEC", "USEC", "NSEC"}; + FILE *file; + int i, j; + + if (argc != 3 || (hz = atol(argv[1])) < 1 + || !(file = !strcmp(argv[2], "-") ? stdout : fopen(argv[2], "w"))) { + fprintf(stderr, "Usage: mktimeconst HZ FILENAME\n\n"); + fprintf(stderr, "Generate a header file with constants to convert between\n"); + fprintf(stderr, "decimal HZ timer ticks and milisecond or microsecond delays,\n"); + fprintf(stderr, "using reciprocal multiplication to avoid 64 bit division.\n"); + exit(1); + } + + fprintf(file, + "/* Conversion constants for HZ == %"PRIu64" */\n\n" + "/* Automatically generated by kernel/time/mktimeconst.c */\n" + "/* This could be generated in __init code but isn't */\n" + + "#ifndef __KERNEL_TIMECONST_H\n" + "#define __KERNEL_TIMECONST_H\n\n" + "#include \n" + "#include \n\n" + "#if HZ != %"PRIu64"\n" + "#error \"include/generated/timeconst.h has the wrong HZ value!\"\n" + "#endif\n\n", hz, hz); + + /* Repeat for MSEC, USEC, and NSEC */ + + for (i = 0; i < 3; i++) { + uint64_t gcd, period; + + /* Find greatest common denominator using Euclid's algorithm. */ + + gcd = hz; + period = periods[i]; + while (period) { + uint64_t temp = gcd % period; + + gcd = period; + period = temp; + } + + /* Output both directions (HZ_TO_PERIOD and PERIOD_TO_HZ) */ + + for (j = 0; j < 2; j++) { + char name[16]; + uint64_t from = j ? periods[i] : hz; + uint64_t to = j ? hz : periods[i]; + uint64_t mul32 = 0, adj32 = 0, shift = 0; + + sprintf(name, j ? "%s_TO_HZ" : "HZ_TO_%s", names[i]); + + /* Figure out what shift value gives 32 significant + * bits of MUL32 data. (Worst case to=1 from=1000000 + * uses 52 bits, to<= (1UL<<31)) + break; + shift++; + } + + /* ADJ32 is just (((FROM/GCD)-1)< 32) { + uint64_t upper, lower; + + upper = (adj32 - 1) << (shift - 32); + lower = (upper % adj32) << 32; + adj32 = ((upper/adj32) << 32) + (lower/adj32); + } else + adj32 = ((adj32 - 1) << shift) / adj32; + + /* Emit the constants into the header file. */ + + fprintf(file, "#define %s_MUL32\tU64_C(0x%"PRIx64")\n", + name, mul32); + fprintf(file, "#define %s_ADJ32\tU64_C(0x%"PRIx64")\n", + name, adj32); + fprintf(file, "#define %s_SHR32\t%"PRIu64"\n", + name, shift); + fprintf(file, "#define %s_NUM\t\tU64_C(%"PRIu64")\n", + name, to/gcd); + fprintf(file, "#define %s_DEN\t\tU64_C(%"PRIu64")\n\n", + name, from/gcd); + } + } + fprintf(file, "#endif /* __KERNEL_TIMECONST_H */\n"); + + /* Notice if the disk fills up. */ + + fflush(file); +} diff --git a/kernel/time/timeconst.bc b/kernel/time/timeconst.bc deleted file mode 100644 index 7ed0e0fb5831..000000000000 --- a/kernel/time/timeconst.bc +++ /dev/null @@ -1,117 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -scale=0 - -define gcd(a,b) { - auto t; - while (b) { - t = b; - b = a % b; - a = t; - } - return a; -} - -/* Division by reciprocal multiplication. */ -define fmul(b,n,d) { - return (2^b*n+d-1)/d; -} - -/* Adjustment factor when a ceiling value is used. Use as: - (imul * n) + (fmulxx * n + fadjxx) >> xx) */ -define fadj(b,n,d) { - auto v; - d = d/gcd(n,d); - v = 2^b*(d-1)/d; - return v; -} - -/* Compute the appropriate mul/adj values as well as a shift count, - which brings the mul value into the range 2^b-1 <= x < 2^b. Such - a shift value will be correct in the signed integer range and off - by at most one in the upper half of the unsigned range. */ -define fmuls(b,n,d) { - auto s, m; - for (s = 0; 1; s++) { - m = fmul(s,n,d); - if (m >= 2^(b-1)) - return s; - } - return 0; -} - -define timeconst(hz) { - print "/* Automatically generated by kernel/time/timeconst.bc */\n" - print "/* Time conversion constants for HZ == ", hz, " */\n" - print "\n" - - print "#ifndef KERNEL_TIMECONST_H\n" - print "#define KERNEL_TIMECONST_H\n\n" - - print "#include \n" - print "#include \n\n" - - print "#if HZ != ", hz, "\n" - print "#error \qinclude/generated/timeconst.h has the wrong HZ value!\q\n" - print "#endif\n\n" - - if (hz < 2) { - print "#error Totally bogus HZ value!\n" - } else { - s=fmuls(32,1000,hz) - obase=16 - print "#define HZ_TO_MSEC_MUL32\tU64_C(0x", fmul(s,1000,hz), ")\n" - print "#define HZ_TO_MSEC_ADJ32\tU64_C(0x", fadj(s,1000,hz), ")\n" - obase=10 - print "#define HZ_TO_MSEC_SHR32\t", s, "\n" - - s=fmuls(32,hz,1000) - obase=16 - print "#define MSEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000), ")\n" - print "#define MSEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000), ")\n" - obase=10 - print "#define MSEC_TO_HZ_SHR32\t", s, "\n" - - obase=10 - cd=gcd(hz,1000) - print "#define HZ_TO_MSEC_NUM\t\t", 1000/cd, "\n" - print "#define HZ_TO_MSEC_DEN\t\t", hz/cd, "\n" - print "#define MSEC_TO_HZ_NUM\t\t", hz/cd, "\n" - print "#define MSEC_TO_HZ_DEN\t\t", 1000/cd, "\n" - print "\n" - - s=fmuls(32,1000000,hz) - obase=16 - print "#define HZ_TO_USEC_MUL32\tU64_C(0x", fmul(s,1000000,hz), ")\n" - print "#define HZ_TO_USEC_ADJ32\tU64_C(0x", fadj(s,1000000,hz), ")\n" - obase=10 - print "#define HZ_TO_USEC_SHR32\t", s, "\n" - - s=fmuls(32,hz,1000000) - obase=16 - print "#define USEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000000), ")\n" - print "#define USEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000000), ")\n" - obase=10 - print "#define USEC_TO_HZ_SHR32\t", s, "\n" - - obase=10 - cd=gcd(hz,1000000) - print "#define HZ_TO_USEC_NUM\t\t", 1000000/cd, "\n" - print "#define HZ_TO_USEC_DEN\t\t", hz/cd, "\n" - print "#define USEC_TO_HZ_NUM\t\t", hz/cd, "\n" - print "#define USEC_TO_HZ_DEN\t\t", 1000000/cd, "\n" - - cd=gcd(hz,1000000000) - print "#define HZ_TO_NSEC_NUM\t\t", 1000000000/cd, "\n" - print "#define HZ_TO_NSEC_DEN\t\t", hz/cd, "\n" - print "#define NSEC_TO_HZ_NUM\t\t", hz/cd, "\n" - print "#define NSEC_TO_HZ_DEN\t\t", 1000000000/cd, "\n" - print "\n" - - print "#endif /* KERNEL_TIMECONST_H */\n" - } - halt -} - -hz = read(); -timeconst(hz) From patchwork Tue Feb 21 21:04:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 60242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp217562wrd; Tue, 21 Feb 2023 12:55:32 -0800 (PST) X-Google-Smtp-Source: AK7set/YekEiZJPaPmX2PEdCIUOHojMvc4+JsxFf8FafyOuEVJzeiz4REziO45IRXXQ4cesKameQ X-Received: by 2002:aa7:cc01:0:b0:4ac:bf55:7d69 with SMTP id q1-20020aa7cc01000000b004acbf557d69mr4665725edt.42.1677012932588; Tue, 21 Feb 2023 12:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677012932; cv=none; d=google.com; s=arc-20160816; b=m3UhsvomKBvtpVs1YJJpymcz+dtH9GGM0LmGUvBbHQXQFAnGzEMX6xSN56b6XOr277 5DHZ3ps5sXZ9/KXN5HL39GqdN49NSwf1nHvOugNP1uSZCOpufArAF0NXDBZMu0lqJBJ0 HJCAScoJwDbCnbf2vPIXGjDw4A2zYIV7UGW/5fIpNmqhfQT0kw6OaWt0t/UP0HqsOVVJ b0M753zykCYyoPvroJuV2dlgy9TV3bpSteVA8ov5m/WChb4LPvrsYSy9w4DEkEdj76J3 mJaRFt80Ixq8BxVAfwMvR1CLJgHiocZjgW8gBECFOWRugzu47al50NYJAhvGJdljTC4q wPEQ== 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:cc :references:to:from:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=r5B8CwFjIlduPhfUcOnrYrohsnN6UDiGn3WQOkB3REk=; b=FEWA0W2lh2EnqkChr3BqvP70KBc6p1fU4cz20H9yCQen0UGMmTuMI1Pp9kRQlg2iJ+ m7pj/Ikg2mDVn3XJkTP4F0cj0VS72pPExW23XuhZHlz1ZWmwNh1VSrtkZiK4zpZSGH68 NpUhbhp6L4S+EbVeVjojqmVTZf3bqcGhTI7h4WOUWUWzdL1RNfYHJgzmkjwXxTb8E/Uf A/oyg6YwZdD46+sMsARFiBQeAsQH1/BuJhBGCuKk2oNxlu5dlFSKsRRpLMfpK/uxYArB /XQnsqN5TKqoSKnN0rzs8chNn8/vWpa3rT+uMbKHmPrqp+yL6Xtl/o4t5cUjVsBR8kE8 zebw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=O0mAq6G2; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a056402069200b004acbe0c5f69si6299276edy.444.2023.02.21.12.55.09; Tue, 21 Feb 2023 12:55:32 -0800 (PST) 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=@landley-net.20210112.gappssmtp.com header.s=20210112 header.b=O0mAq6G2; 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 S229836AbjBUUu4 (ORCPT + 99 others); Tue, 21 Feb 2023 15:50:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbjBUUuz (ORCPT ); Tue, 21 Feb 2023 15:50:55 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540DD2916A for ; Tue, 21 Feb 2023 12:50:54 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id d11so2275113iow.0 for ; Tue, 21 Feb 2023 12:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=r5B8CwFjIlduPhfUcOnrYrohsnN6UDiGn3WQOkB3REk=; b=O0mAq6G2PEH7QqEa6nGbO0AZSMLn66Jtoq9LYk+DsQzEEnKP7y6uVwtUpCGqYolxWJ poi4Vv3k6yc5cq1DkRK3QWZ2SBqPvdhAKD0O/6vWrCxbEISRjZeUOK4nnCEw9rvPPgdy 3jNwmMMvFkA1wXydNocr9NLTPRFlsDvscy9ivYfMSCjJxWUpZBG2T6ZTlEOGF+yrK4li ZHTWZDWd4OFaN32fn/AM2FOLMmSiqNiLE2LX+xL8Jfe0YUo3OVaUfbm80FcCObf++jcr cQGl6OkjzK2IJrpneoqRXsRxECKnmbv6RcpLvBztjnpf4xOZWlSb3rxjoxamS3nw/eW3 DHmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:cc:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r5B8CwFjIlduPhfUcOnrYrohsnN6UDiGn3WQOkB3REk=; b=diSWco5tyBnu6kYs0hVMSrsjxVIM83T/x2F4Oj52nSfa/BjtrYhVrJL4izkIGIwxx4 zonFMRjMiR4tvaqFz31NOeV3u6QBRvlIotckrP1rKVdlrcOCVYJhcD/QP1nuLHElGOE6 tTB7XFVeQGyceK9Mnk6ANNJCM0JP7oOvgBTaHGbdgwYwXsfABZRBMWtqtLo1XdNmlQ01 DjqayioNZ9WG5dXxbGiJfipb+MDrhS5KUJLYCU0AERbQqxrrVRKHAQ55otl/eEFYruoB 2IysME/nDgMZ9IfJmY5h4joyfkL8+BX+Q4JCYEBSa5/MD0T70SUzqyxJKT9uAfa3x68v yBZg== X-Gm-Message-State: AO0yUKX7iaSt7w3yONQN/LhSvs2VLMnHNDm5S4KJs8+1medIrAISZ38W 4hn0rZOe6vyWBCvqtjxZykMf7WkN/qC4Uqqm1VE= X-Received: by 2002:a5d:8184:0:b0:746:c45f:f151 with SMTP id u4-20020a5d8184000000b00746c45ff151mr9388380ion.3.1677012653497; Tue, 21 Feb 2023 12:50:53 -0800 (PST) Received: from [172.16.32.78] ([198.232.126.202]) by smtp.gmail.com with ESMTPSA id t17-20020a6b0911000000b00745a82f892bsm188888ioi.15.2023.02.21.12.50.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Feb 2023 12:50:53 -0800 (PST) Message-ID: <8244c75f-445e-b15b-9dbf-266e7ca666e2@landley.net> Date: Tue, 21 Feb 2023 15:04:15 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH 5/5] fix rootfstype=tmpfs Content-Language: en-US From: Rob Landley To: "linux-kernel@vger.kernel.org" References: Cc: Andrew Morton , Wolfram Sang In-Reply-To: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,URI_DOTEDU autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758475512339090571?= X-GMAIL-MSGID: =?utf-8?q?1758475512339090571?= Wire up rootfstype=tmpfs to force rootfs to be tmpfs even when you specify root= Initramfs automatically uses tmpfs (if available) when you DON'T specify a root= fallback root to mount over initramfs, but some people can't NOT do that for some reason (old bootloaders), so let rootfstype=tmpfs override it. My original code tried to do this 10 years ago but got the test wrong, and nobody's corrected it since, so here you go... Signed-off-by: Rob Landley See https://lkml.iu.edu/hypermail/linux/kernel/2207.3/06939.html Reviewed-by: Stefan Berger Tested-by: Stefan Berger --- init/do_mounts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/do_mounts.c b/init/do_mounts.c index 811e94daf0a8..01d80fb828fd 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c @@ -665,7 +665,7 @@ struct file_system_type rootfs_fs_type = { void __init init_rootfs(void) { - if (IS_ENABLED(CONFIG_TMPFS) && !saved_root_name[0] && - (!root_fs_names || strstr(root_fs_names, "tmpfs"))) + if (IS_ENABLED(CONFIG_TMPFS) && (!root_fs_names ? !saved_root_name[0] : + !!strstr(root_fs_names, "tmpfs"))) is_tmpfs = true; }