Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp50973rwd; Sat, 13 May 2023 12:41:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4YFgoePIO9NHbNoEGTByQqBSb4M8bYjDn/ew4b7EJ0jEH5KQ8Vsqa+OLFc1xPZ6h6A+lST X-Received: by 2002:a17:90b:2307:b0:24e:165d:8f65 with SMTP id mt7-20020a17090b230700b0024e165d8f65mr27829257pjb.5.1684006868454; Sat, 13 May 2023 12:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684006868; cv=none; d=google.com; s=arc-20160816; b=a3MJtx8f445/Tg3VUl/bNCPhPt8OJN0HMd5jI7RACEMIcZ7mzseWRyD3Yw9q8niTrt MRZTmM4YKSfoAAjMEEgGKNRyKw0i0ATPmSUK67ODcbDQNtznNTXZnmy0L3PG3xL5uYTe dCe4YoQ/BMgqloVZ386jxjN/xcSEr9nIm4ytSz3JA92mr46eASYhI1zSpQD3rQjScDlw Go5yuX5BOtPa6YM/poOgkiAxCsWCU/LC96wWDDmIF3TlWOLa1dOycc9ajM5BI+GCJMIa lfhJ0DYUUcvih8oXBknSiAjJSDKuBaIKYnx9jKxrEovPuc+7ppScyjCAiLAT6fWmnu2V /C5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=pZ3u1CrwwU+GfMaup+iHwAK48qBfxEDVoofnNqrsG9Q=; b=DfvMMZht29XXtHL754OZpX6tkBU3gKulNp0Q+NlSHZAM6Zz/Ld/8r9CgV1o82p18ac 7HHMWY70yyugrMwHoDLWBClYyJorXi5Y+Mqjo+H7YuUDT/sKyXRoqhIzpnc/lDYXGVGS vB7YbtRGGo3AnAXXxAY1naYI1FCMuJjK5ZvnRq5/TrX55PKHjBO7E6wZJEETTnBWnQZk f8hBrf9JN8HW2ttSJOZr63FlPgerb145XI2xClIEHJRvcXqTVq9Nz+jhcxtuASOzSuAf pw5tnjh01HIHenm9SIMKpoQnS847nDKTA1T4Xh9Y5pc5wyLSlWgHnbSrfGushizG2gGn RH/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ic7SAyuo; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 19-20020a631753000000b00513234112a7si11564906pgx.883.2023.05.13.12.40.56; Sat, 13 May 2023 12:41:08 -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=@linux.dev header.s=key1 header.b=ic7SAyuo; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233014AbjEMT22 (ORCPT + 99 others); Sat, 13 May 2023 15:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbjEMT2Z (ORCPT ); Sat, 13 May 2023 15:28:25 -0400 Received: from out-40.mta1.migadu.com (out-40.mta1.migadu.com [IPv6:2001:41d0:203:375::28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 140D6CA for ; Sat, 13 May 2023 12:28:24 -0700 (PDT) Date: Sat, 13 May 2023 15:28:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684006102; 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: in-reply-to:in-reply-to:references:references; bh=pZ3u1CrwwU+GfMaup+iHwAK48qBfxEDVoofnNqrsG9Q=; b=ic7SAyuoFp7zwWIDHRTVlp796UJt9qNLi/31Bt8w/eCvrxJAb8ItdBTWHvxvgXQZJkAdl+ FdMITYl/2Ym4nlasoNe8vjuG6KbqiFsHqo5dDLibdpNfqcrjAT+w8d+fZfRUflQOypYJJ8 V2GD34J/75ugp2k6hJHTyqYEl5dsKQQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Eric Biggers Cc: Lorenzo Stoakes , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org, Kent Overstreet , Andrew Morton , Uladzislau Rezki , linux-mm@kvack.org Subject: Re: [PATCH 07/32] mm: Bring back vmalloc_exec Message-ID: References: <20230509165657.1735798-1-kent.overstreet@linux.dev> <20230509165657.1735798-8-kent.overstreet@linux.dev> <20230510064849.GC1851@quark.localdomain> <20230513015752.GC3033@quark.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230513015752.GC3033@quark.localdomain> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Fri, May 12, 2023 at 06:57:52PM -0700, Eric Biggers wrote: > What I would suggest instead is preprocessing the list of 6 field lengths to > create some information that can be used to extract all 6 fields branchlessly > with no dependencies between different fields. (And you clearly *can* add a > preprocessing step, as you already have one -- the dynamic code generator.) > > So, something like the following: > > const struct field_info *info = &format->fields[0]; > > field0 = (in->u64s[info->word_idx] >> info->shift1) & info->mask; > field0 |= in->u64s[info->word_idx - 1] >> info->shift2; > > ... but with the code for all 6 fields interleaved. > > On modern CPUs, I think that would be faster than your current C code. > > You could do better by creating variants that are specialized for specific > common sets of parameters. During "preprocessing", you would select a variant > and set an enum accordingly. During decoding, you would switch on that enum and > call the appropriate variant. (This could also be done with a function pointer, > of course, but indirect calls are slow these days...) > > For example, you mentioned that 8-byte packed keys is a common case. In that > case there is only a single u64 to decode from, so you could create a function > that just handles that case: > > field0 = (word >> info->shift) & info->mask; > > You could also create other variants, e.g.: > > - 16-byte packed keys (which you mentioned are common) > - Some specific set of fields have zero width so don't need to be extracted > (which it sounds like is common, or is it different fields each time?) > - All fields having specific lengths (are there any particularly common cases?) > > Have you considered any of these ideas? I like that idea. Gonna hack some code... :)