From patchwork Wed Jun 12 16:52:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 1947040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Mpb4pYdD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vzs6h5gQlz20Pb for ; Thu, 13 Jun 2024 02:53:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08DC2388216B for ; Wed, 12 Jun 2024 16:52:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 519C43875DD1 for ; Wed, 12 Jun 2024 16:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 519C43875DD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 519C43875DD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718211165; cv=none; b=kiBE1Ovj1u8p+Hyvb+zFVjohVFhvQCLS7gAbHla9El+OK8D9YkwcVeNR/islkqZVyqrdC0O23FYgI3pRKacqkEH8XNy3rZ0L+xVr/UAhs7Ilhva4FhxE4ojVUldPzcvP4rGnjbzJluNXR99ltFodlbiVCFRA81FXB+NIwKgd+Uw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718211165; c=relaxed/simple; bh=EmiCLM1oNfGOqb2bnX+ejUVMzF1de8BOOPnsVnub/W0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qIwwIM9J6cnA75awAUz32GoSMjFW0Fh7hogykjVh/rCQgwfZmt9sggYEstUYKQFS8t4m53bb5Nxxs3z9Yx+uunjexTIpGNNiDAsFfMkcTixM0/2wmOIkDP0Pm/Kqc78voNWixol/6kyHTkGjIpPQGzI8jLEiqc1b9GKC7rnKKN0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718211164; 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; bh=nL8H1EqaVEYQctmI9QvvHReI/GBuUVKuN1gUMO9r9p0=; b=Mpb4pYdD7tU01TqweoTZjsni6ZsMEnhSVQHY8mwFpT+vG1VTa9xK1Zdvtf8twE5RC7hr2m dSB9la8cWkpD1H3uQO7fsg7iI8f0x53xUahh+Fh+t+KtOJUNnn8ugE5Mbo5lXMpPZtOj6j SkqZ+hP4YMRFbLvfiOVFzkKBDaLc0TI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-hdYosCBUMtqXdVzIuAycRg-1; Wed, 12 Jun 2024 12:52:42 -0400 X-MC-Unique: hdYosCBUMtqXdVzIuAycRg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 91BCE1956094 for ; Wed, 12 Jun 2024 16:52:41 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.8.94]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 36E433000627; Wed, 12 Jun 2024 16:52:41 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.16.1/8.16.1) with ESMTP id 45CGqYxo1432149; Wed, 12 Jun 2024 12:52:34 -0400 From: DJ Delorie To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: [v2] tunables: sort tunables list Date: Wed, 12 Jun 2024 12:52:34 -0400 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, 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 server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Florian Weimer writes: > We already require GNU awk and use asorti, so I'd prefer built-in > sorting here, too. Ok. > The other mechanics look right to me. I remember doing something > similar, but must have discarded it because of the issue you mentioned > before (new tunables landing in the middle of the list). I did a test where I added a new tunable at the end of the last *.list given to the original script. It added it third in the final output. So we *already* have the "new tunables change most of the tunable IDs" and sorting the list only changes how many IDs change, not whether any do. The POSIX spec specifically says that "foo in bar" returns entries in no particular order, too, so any consistency is coincidental. Sorting makes the output explicitly consistent. [v2: use asorti()] diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk index fc3b41376f..d9f326b63b 100644 --- a/scripts/gen-tunables.awk +++ b/scripts/gen-tunables.awk @@ -131,6 +131,11 @@ END { exit 1 } + # TYPES is an associative array where the index is the data + # TYPESA is an indexed array where the value is the data + # We sort TYPESA + typecount = asorti (types, typesa) + print "/* AUTOGENERATED by gen-tunables.awk. */" print "#ifndef _TUNABLES_H_" print "# error \"Do not include this file directly.\"" @@ -141,7 +146,8 @@ END { # Now, the enum names print "\ntypedef enum" print "{" - for (tnm in types) { + for (i = 1; i <= typecount; i++) { + tnm = typesa[i]; split (tnm, indices, SUBSEP); t = indices[1]; n = indices[2]; @@ -157,7 +163,8 @@ END { print "# include \"dl-tunable-types.h\"" # Finally, the tunable list. print "static tunable_t tunable_list[] attribute_relro __attribute_used__ = {" - for (tnm in types) { + for (i = 1; i <= typecount; i++) { + tnm = typesa[i]; split (tnm, indices, SUBSEP); t = indices[1]; n = indices[2]; @@ -172,7 +179,8 @@ END { # Map of tunable with environment variables aliases used during parsing. */ print "\nstatic const tunable_id_t tunable_env_alias_list[] =" printf "{\n" - for (tnm in types) { + for (i = 1; i <= typecount; i++) { + tnm = typesa[i]; split (tnm, indices, SUBSEP); t = indices[1]; n = indices[2];