From patchwork Sun Apr 23 21:55:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1772497 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=8.43.85.97; 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=vVIvK/hl; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4Q4MXt305wz23hs for ; Mon, 24 Apr 2023 07:56:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DFCC385771D for ; Sun, 23 Apr 2023 21:56:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DFCC385771D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682286988; bh=qBeAdZi81iccaLmE7yPrSBBu/BngQeSeDsQzDPS4YDc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=vVIvK/hlvZYnAdZf0irlr+D4RKkSawI3hogElFHDKP9uEthmIASg48Ls3lj3xVPm3 FLV/1RThyAz3UV6UXdtpJ7ePA9wgR+HTYtxV4WJB/Fxp5s11m4XTnBKgKzmdeOODLt WlsQJXA40g/5YdPCguuZunDTZSz6xBxeGtAwLLrY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 236003858C53 for ; Sun, 23 Apr 2023 21:55:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 236003858C53 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4eff1f7f34bso193177e87.0 for ; Sun, 23 Apr 2023 14:55:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682286930; x=1684878930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qBeAdZi81iccaLmE7yPrSBBu/BngQeSeDsQzDPS4YDc=; b=SwFvISGaEYWX3/LaIWDJW3dQNKmjHp9O24gzrPqlHLpnWg9cjqSogQUg+iqt15UzbJ BocJ4uEdykpI9QfLeQvsml1mwmwdbeqrVtO5DdTBosl8imWVdNxiQ64DXG9+oinsYAQX hhjg2u7Z0SghivOuwQmAxHCD8YRX3liSa8cbxBgDQ6Nl2RpVyllu0VvC9Dj2O0A4uF5G reqN9p2fOm+goVXdu65zrAK7JttehZCwnV6FXajwmd6Cz5mwVNYYbX3MSwNg2KKdLVUq nkfrqZyvuFhDMpbj8H3+QWg+jnI5CDxw9QoCb/bhiHVVWxeh25iOJXfxlZCrko9nXpQw o2jw== X-Gm-Message-State: AAQBX9eu4RhNXBfGxzOtMbYHfPw3JnEU/tCdKjQfNuW7cEDePSNCCRLD z4Aal8qQRixP3+Dstyw3TMg2gvU9ExVYKQ== X-Google-Smtp-Source: AKy350ZqJeQ1b4yIk3ghSE8J9kCwnowEIE5SBNfFNqNvJpURxdfdEsY2AhxwuSXYGjbm4iduKyo6eg== X-Received: by 2002:a05:6512:243:b0:4e0:ff8e:bbfe with SMTP id b3-20020a056512024300b004e0ff8ebbfemr2881460lfo.12.1682286930206; Sun, 23 Apr 2023 14:55:30 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:e26d:6595:78ee:6d64]) by smtp.gmail.com with ESMTPSA id q8-20020ac25a08000000b004ecb06acbb3sm1393905lfn.281.2023.04.23.14.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 14:55:29 -0700 (PDT) To: libc-alpha@sourceware.org Cc: bug-hurd@gnu.org, Samuel Thibault Subject: [PATCH 3/4] hurd: Microoptimize mmap () Date: Mon, 24 Apr 2023 00:55:25 +0300 Message-Id: <20230423215526.346009-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230423215526.346009-1-bugaevc@gmail.com> References: <20230423215526.346009-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/mmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sysdeps/mach/hurd/mmap.c b/sysdeps/mach/hurd/mmap.c index 790eb238..d570be24 100644 --- a/sysdeps/mach/hurd/mmap.c +++ b/sysdeps/mach/hurd/mmap.c @@ -42,7 +42,8 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) mapaddr = (vm_address_t) addr; /* ADDR and OFFSET must be page-aligned. */ - if ((mapaddr & (__vm_page_size - 1)) || (offset & (__vm_page_size - 1))) + if (__glibc_unlikely ((mapaddr & (__vm_page_size - 1)) + || (offset & (__vm_page_size - 1)))) return (void *) (long int) __hurd_fail (EINVAL); vmprot = VM_PROT_NONE; @@ -73,7 +74,8 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) mach_port_t robj, wobj; if (err = HURD_DPORT_USE (fd, __io_map (port, &robj, &wobj))) { - if (err == MIG_BAD_ID || err == EOPNOTSUPP || err == ENOSYS) + if (__glibc_unlikely (err == MIG_BAD_ID || err == EOPNOTSUPP + || err == ENOSYS)) err = ENODEV; /* File descriptor doesn't support mmap. */ return (void *) (long int) __hurd_dfail (fd, err); } @@ -173,7 +175,7 @@ __mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) if (err == KERN_PROTECTION_FAILURE) err = EACCES; - if (err) + if (__glibc_unlikely (err)) return (void *) (long int) __hurd_fail (err); return (void *) mapaddr;