From patchwork Mon Feb 13 13:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1741661 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Chwgr0NN; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PFmBW3nCbz23h0 for ; Tue, 14 Feb 2023 00:57:55 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8096C3894C05 for ; Mon, 13 Feb 2023 13:57:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8096C3894C05 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676296673; bh=5X3V4gc/RB6i4215oZIIHFeCMg277b5TgmujLqutqoQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Chwgr0NNdoEfg3JlBw3QhTfIhpkq4i479UA5iW7OiG8+cQV89eOnlpNi5wNhbPh1+ Ahx66ia9Tqzp1cNpJG3zmYeFwXUGMIuoUmsR+oRAhHChIRdICmk3vVIzR388Hx1Dd4 gftyswzM9faraA5QoZPGAF6rh+bwKiknNW44NzSA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by sourceware.org (Postfix) with ESMTPS id 4CBBB383FBAF for ; Mon, 13 Feb 2023 13:56:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CBBB383FBAF Received: by mail-oo1-xc2b.google.com with SMTP id r192-20020a4a37c9000000b00517677496d0so1181566oor.13 for ; Mon, 13 Feb 2023 05:56:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5X3V4gc/RB6i4215oZIIHFeCMg277b5TgmujLqutqoQ=; b=JFe07yKVgnlD/TIJyovJI4CNAQ3UW2UV8wHSqv9pf+1xhPTtRImwrd73NCSj/F4W2Z I1/xgK1xdiptSiHM2dOLfrpJmwMu2nbi7Z/6hZ2+iRQ4uDmJljz6vy2AJdvKSQxsTcId J/eGPvpmkmteNQPTLu+qn99KMmbkzxW9xOxE338IuooXC1MMwoD5/NGah6R2EfWlaCyI 70bYiT7fXqnzf8x48BYfXIDD8kzkN14pwl+xclKBnW83shq26yt0T5S/NYHFk92gJiqS ltajordnjtnTnSm6eSnuTleSzIrdm2xSTEc1TqFGc3bgxua0hoCpOmJfn8tLl7XmS9nk z6Gw== X-Gm-Message-State: AO0yUKW/QYNFlKinrWL6Hmlt74v0UD3ANBQPXOmoNqA+7vT+RCCuSimc /WyGek2aB9z8aNPQICphVeDCSiEaal2vdyEaI/A= X-Google-Smtp-Source: AK7set+4S66hcayVTx7d5VgRbKud1aMkxkVoosRAcntYBEX2SmJkLR7OKKFcQXXw/koXU7sNPNfPXw== X-Received: by 2002:a4a:2c51:0:b0:517:67ba:586 with SMTP id o78-20020a4a2c51000000b0051767ba0586mr11336037ooo.3.1676296567978; Mon, 13 Feb 2023 05:56:07 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:f662:138b:cd0c:7b7a:8860]) by smtp.gmail.com with ESMTPSA id y11-20020a4ade0b000000b0051762a73553sm4797168oot.18.2023.02.13.05.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 05:56:07 -0800 (PST) To: libc-alpha@sourceware.org, Wilco Dijkstra Subject: [PATCH 3/7] nscd: Remove _STRING_ARCH_unaligned usage Date: Mon, 13 Feb 2023 10:55:54 -0300 Message-Id: <20230213135558.3328727-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> References: <20230213135558.3328727-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" It only adds a small overhead for unaligned inputs (which should not be common) and unify the code. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra   --- nscd/nscd_gethst_r.c | 2 -- nscd/nscd_getserv_r.c | 2 -- nscd/nscd_helper.c | 6 ------ 3 files changed, 10 deletions(-) diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index 7950ed695c..153194ad04 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -185,7 +185,6 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, goto out; } -#if !_STRING_ARCH_unaligned /* The aliases_len array in the mapped database might very well be unaligned. We will access it word-wise so on platforms which do not tolerate unaligned accesses we @@ -199,7 +198,6 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, hst_resp.h_aliases_cnt * sizeof (uint32_t)); } -#endif if (type != GETHOSTBYADDR && type != GETHOSTBYNAME) { if (hst_resp.h_length == INADDRSZ) diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c index 752ae1115e..0ee83ff88c 100644 --- a/nscd/nscd_getserv_r.c +++ b/nscd/nscd_getserv_r.c @@ -140,7 +140,6 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, > recend, 0)) goto out; -#if !_STRING_ARCH_unaligned /* The aliases_len array in the mapped database might very well be unaligned. We will access it word-wise so on platforms which do not tolerate unaligned accesses we @@ -170,7 +169,6 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto, serv_resp.s_aliases_cnt * sizeof (uint32_t)); } -#endif } } diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index fdd555ea66..6a498b363c 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -465,7 +465,6 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, struct hashentry *here = (struct hashentry *) (mapped->data + work); ref_t here_key, here_packet; -#if !_STRING_ARCH_unaligned /* Although during garbage collection when moving struct hashentry records around we first copy from old to new location and then adjust pointer from previous hashentry to it, there is no barrier @@ -474,7 +473,6 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, application. */ if ((uintptr_t) here & (__alignof__ (*here) - 1)) return NULL; -#endif if (type == here->type && keylen == here->len @@ -487,10 +485,8 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, struct datahead *dh = (struct datahead *) (mapped->data + here_packet); -#if !_STRING_ARCH_unaligned if ((uintptr_t) dh & (__alignof__ (*dh) - 1)) return NULL; -#endif /* See whether we must ignore the entry or whether something is wrong because garbage collection is in progress. */ @@ -511,11 +507,9 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, struct hashentry *trailelem; trailelem = (struct hashentry *) (mapped->data + trail); -#if !_STRING_ARCH_unaligned /* We have to redo the checks. Maybe the data changed. */ if ((uintptr_t) trailelem & (__alignof__ (*trailelem) - 1)) return NULL; -#endif if (trail + MINIMUM_HASHENTRY_SIZE > datasize) return NULL;