From patchwork Fri Dec 22 07:46:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13503066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47890C41535 for ; Fri, 22 Dec 2023 07:46:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F7586B0072; Fri, 22 Dec 2023 02:46:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A5B26B0074; Fri, 22 Dec 2023 02:46:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 494AC6B0075; Fri, 22 Dec 2023 02:46:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3658B6B0072 for ; Fri, 22 Dec 2023 02:46:36 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F3F1A807F8 for ; Fri, 22 Dec 2023 07:46:35 +0000 (UTC) X-FDA: 81593671950.09.E63365C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id C774F140015 for ; Fri, 22 Dec 2023 07:46:33 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="S8wWR4r/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703231194; a=rsa-sha256; cv=none; b=Z7hIw9RqOUMtLt6oZIkZVChxNUxIYrjcSo48UHPcy0ZxhwjI+57WpVP2SHuk7t9+YMGxPW j6nVgxmqQpeSBn3CMxTBSmV9jsK3bu8IgO0qtEiG14cxB2mjiiFaot3uFzDjJ8fYMP4Uhu VfA9momnmU3pi/Wr86Emx9LVfrxJgzI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="S8wWR4r/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703231194; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=8joa0SqsNw6lghVtjrUIlISHZyZgU8xVLriDEJzMbbU=; b=EdV6Tqy1NcqvF/X6zcghi1zRWINq8CzNrbnQjTqFVRzfS2dKNVFO3RowYHN4WzTFgnP5nY OBGt7X6MIOkC9ZWpbXCZ18uSFw8B93NDVGOtQgaC5jn9f59Ej1LzGSZCAaUup1gtn6Q9nK k8tgHducGsiLnKxKV7m5ZPlCkzJ8mz4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703231193; 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: content-transfer-encoding:content-transfer-encoding; bh=8joa0SqsNw6lghVtjrUIlISHZyZgU8xVLriDEJzMbbU=; b=S8wWR4r/e0eUM3vRk61rARfj7DYPTDmij2x/MB9mcFo0oYVaiWsf5SjACcMyqXlQ29sNGH hY1VZJBoj/PXvsKYj2CMNmqPHyhTJC5b2VCwoXSy5lyvHkG7CunPdAJX6vKFnh5bZP+ymE 2NxjA7t6ensfXExGOQh5cnAjTjWkdSg= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-494-AcQobL7CNvSg4mjeEkSrTw-1; Fri, 22 Dec 2023 02:46:31 -0500 X-MC-Unique: AcQobL7CNvSg4mjeEkSrTw-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-6dbac6bb6b6so1783023a34.1 for ; Thu, 21 Dec 2023 23:46:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703231190; x=1703835990; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8joa0SqsNw6lghVtjrUIlISHZyZgU8xVLriDEJzMbbU=; b=uwRMOw8qF/9fvFsjJ6w5znvAaxS4aCRzULLi0RmyXMOFn5viXCbyMHqUFlK93EV/3y EHzNHmvLX8FuGSD4mTxl9ME/eK+FAWjvsWB9JCZfi8EtdNnu99jcwAE+ikIlkRuDex/O C07OC4gwPmUuzjDf7JyyD5EznkuzPeAS4NcqJ0DSiM5Ati1H952sXIOkTrqyJ+x6RnYv xpHYrFzRyqdwha7l2TrMMaQHNYRSeKvEWh1S/Uc/71IitONHUoB+UECPS1M49Zhh/ITl pBvRDw0bwOVM/OcTdeCL1S5eiq+yip9DXSSaeCBH7TOxdu0/wtbFt3q/uSOkQCNpO5qD FlYQ== X-Gm-Message-State: AOJu0Ywd0MG5qANTyngw+JN1dWn4dEYsAHu+p14sCNFVkvnuHi4cFsET XjcZS5cf6SM8K6/UZhPdcSRL9klDJh48UysSFq9U64oNSspzwEoY4XSOEUBmk8oO4FIMdBOc2ox rzaYZH2pG+YMUmb4anz8= X-Received: by 2002:a05:6830:188:b0:6d8:7b83:b520 with SMTP id q8-20020a056830018800b006d87b83b520mr975575ota.22.1703231190649; Thu, 21 Dec 2023 23:46:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtPKXrNxbzqoFd8PBPnac2PBZhiVN9/33Wde7wZTDupuDnjdqviH8QQZhwIVNY+bNVq43CLg== X-Received: by 2002:a05:6830:188:b0:6d8:7b83:b520 with SMTP id q8-20020a056830018800b006d87b83b520mr975547ota.22.1703231190419; Thu, 21 Dec 2023 23:46:30 -0800 (PST) Received: from localhost.localdomain ([2804:1b3:a802:7496:88a7:1b1a:a837:bebf]) by smtp.gmail.com with ESMTPSA id m2-20020a62f202000000b006d97eaba6cesm1527015pfh.21.2023.12.21.23.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 23:46:29 -0800 (PST) From: Leonardo Bras To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Eric Biederman , Kees Cook , Oleg Nesterov , Leonardo Bras , Conor Dooley , Andy Chiu , Greg Ungerer , Vincent Chen , Xiao Wang , Charlie Jenkins , Andrew Morton , Alexandre Ghiti , Kemeng Shi , David Hildenbrand , "Matthew Wilcox (Oracle)" , Qinglin Pan , Greentime Hu , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , =?utf-8?b?Q2zDqW1l?= =?utf-8?b?bnQgTMOpZ2Vy?= , Guo Ren Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 0/4] Introduce & Optimize compat-mode helpers Date: Fri, 22 Dec 2023 04:46:00 -0300 Message-ID: <20231222074605.452452-1-leobras@redhat.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C774F140015 X-Stat-Signature: m69tkhr6yqdjx3qja491kp894a7gjbjs X-HE-Tag: 1703231193-847105 X-HE-Meta: U2FsdGVkX1/LZE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xURd15744QDvNGj8ujgJNsNp2Ijd42aQBfgh2H4sZY4qaDK3808PTD4MxDrx6L2J45Kg8rGcDQ/lJ40lOefoH+Hz/mx7sjExIF6K8XNPw/ljdgu6boejk2Kxy9iH0hcZsxcrW6FOG7lKgSvGPdQtDpW3/JY8yXQrzoZIuS8itQNnoTRmvVn7D/DmB6rbLq95aATx8g1Y9FL2qLnJ8XrRrJMstVdOQGZfEI3XQL41/fRZqaM6Tevw4qF7XVswFuT7ugvvA7TAVv748UZtUzjD2g9R9p1p6UsyPFQAy1AMlLNJddsMQDVWaI7w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000025, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: I just saw the opportunity of optimizing the helper is_compat_task() by introducing a compile-time test, and it made possible to remove some #ifdef's without any loss of performance. I also saw the possibility of removing the direct check of task flags from general code, and concentrated it in asm/compat.h by creating a few more helpers, which in the end helped optimize code. Leonardo Bras (4): riscv: Replace direct thread flag check with is_compat_task() riscv: add compile-time test into is_compat_task() riscv: Introduce is_compat_thread() into compat.h riscv: Introduce set_compat_task() in asm/compat.h arch/riscv/include/asm/compat.h | 19 +++++++++++++++++++ arch/riscv/include/asm/elf.h | 11 ++--------- arch/riscv/include/asm/pgtable.h | 8 +------- arch/riscv/include/asm/processor.h | 4 ++-- arch/riscv/kernel/ptrace.c | 6 +++--- 5 files changed, 27 insertions(+), 21 deletions(-) base-commit: 24e0d2e527a39f64caeb2e6be39ad5396fb2da5e