Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1181327rdb; Fri, 22 Dec 2023 18:52:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGU+XaAHcAkj6Fi+M7gI4jUGC8otsX18MqZnCgy0/jFv/VaM3FznrKQHUKuHqpGXxiFywiG X-Received: by 2002:ac8:5c48:0:b0:425:4042:f456 with SMTP id j8-20020ac85c48000000b004254042f456mr3525946qtj.58.1703299977593; Fri, 22 Dec 2023 18:52:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703299977; cv=none; d=google.com; s=arc-20160816; b=oPiO77KNE+Jg538eLgtituSpLElb0t79c/9zebcThy9/RFaSZwELap3QDkEa1pbFrw wBTETR/gDYz0lAz265TRnJjrXpNbpTHhVVcb3Ptgrr4uPo2pQPCMcuXlmrDEGot0Kcmi kpPOPveIhKcHe+sc3NNTgaVhNBXjPEirDuKHbYaCW32+98iOFga/vi/HtonI5+zJMz4k 5btYukGpDIq9gtUHfOo7b6k7NreTncx4Dky/EoETCUacNSMh4gwVWVAbOApt04Kzt7gh wVCix/1lystxi8Sgx4ey9rHNR5Or4iKTTyOL13fCT8ryFr+rMhHorYugWiB1J8hD/wMj TTTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=PtIuL6ZU4b2ovfQHGZduN9XMmQPkSAdeaCW8acsnw8s=; fh=A78Ob4OkQhcrc9fF2kCzUxJhWq20+Me+Hfow3c50/jM=; b=hvDhCyKcuaXGJznasJvY1LnIeOxwtPeIhwco+gDJ1QxZs7gPsEsQPT3jnkB/KZceFh pJaA0jZKub53ihjPUjE4s6Mf8SPoIFLsakpOvoOvIlUamP0W7mEkvY7fiZOPkOufPYqu TesznTyvXqwpqWxgU75PdcLAEgZ/FJvHHVApTXMu2ysLUxvXLhaTvo8ckg1Pphj+SlJw mRAs1MWjpRV/MwPonXPescmQMIF0Vrt1qNhaLwov3hbi9iQ4WbMJQmfGh24lzIBopH+Q RrSBkMR7niTCTeDwpuqan2/a8t4Ul4QfqmIZkWkzJUuScd8OgV1Xg4tmIvZH6lexzFY4 8HUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LQh3OKkE; spf=pass (google.com: domain of linux-kernel+bounces-10213-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v8-20020a05622a014800b00423d2eb0b37si5846794qtw.21.2023.12.22.18.52.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 18:52:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10213-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LQh3OKkE; spf=pass (google.com: domain of linux-kernel+bounces-10213-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10213-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5D27F1C2188A for ; Sat, 23 Dec 2023 02:52:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7C0A1392; Sat, 23 Dec 2023 02:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LQh3OKkE" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA0261368 for ; Sat, 23 Dec 2023 02:52:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 621EFC433D9 for ; Sat, 23 Dec 2023 02:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703299969; bh=rGnjRsJeeEvv71gmE5cTVsYlTCyd72dN5f4IXTVEfoM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=LQh3OKkE3rSV4uLpymgW+d9EI1/XuHbmbyO5rf2XHRh3VnMJVKXJAuYM/ivMIYzNc JL5l5ff2zFR+Lf4CapDVYEOTxKLdqIQ+IHBXps0d+MqCX+J6ui6MOOF46emXCNsyu5 yz+dxshxQH/QZA8i+crBkslhoAq2sO4qC4jnMQizE/cbpCSbb8FE2sDRcSX7q7fwE9 1mrOcIisJGojcOZGwXp20SxrYS4aIVRaWGARLU936nzIjuVEpQ+gj+1/Hf/v93o2nJ /xEQ5L0uazoDBerVoAx42w+A4J1uZcM2odFsVNvjXSvvk55d2yAv206pWwOzRANLlx 3LlM2zHW5RqsQ== Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-55485e45ef9so187105a12.3 for ; Fri, 22 Dec 2023 18:52:49 -0800 (PST) X-Gm-Message-State: AOJu0YxbJbZdN0UCtQ0M8cYTdHq1XfImx5B4+Qjd+wjyan72N4ugohjI 5du7fSq19bpJFwyysZEYlIRG0iZmkGFIYGRUpZc= X-Received: by 2002:a17:906:25d:b0:a26:98ff:6464 with SMTP id 29-20020a170906025d00b00a2698ff6464mr1182977ejl.17.1703299967812; Fri, 22 Dec 2023 18:52:47 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231221154702.2267684-1-guoren@kernel.org> <20231221154702.2267684-5-guoren@kernel.org> In-Reply-To: From: Guo Ren Date: Sat, 23 Dec 2023 10:52:36 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V2 4/4] riscv: mm: Optimize TASK_SIZE definition To: David Laight Cc: Leonardo Bras , "linux-kernel@vger.kernel.org" , "paul.walmsley@sifive.com" , "palmer@dabbelt.com" , "alexghiti@rivosinc.com" , "charlie@rivosinc.com" , "xiao.w.wang@intel.com" , "david@redhat.com" , "panqinglin2020@iscas.ac.cn" , "rick.p.edgecombe@intel.com" , "willy@infradead.org" , "bjorn@rivosinc.com" , "conor.dooley@microchip.com" , "cleger@rivosinc.com" , "linux-riscv@lists.infradead.org" , Guo Ren Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 22, 2023 at 7:52=E2=80=AFPM David Laight wrote: > > From: Guo Ren > > Sent: 22 December 2023 11:25 > ... > > > > +#define TASK_SIZE (is_compat_task() ? \ > > > > TASK_SIZE_32 : TASK_SIZE_64) > > I would remove is_compat_task() in the next version because your patch > > contains that. > > Does TASK_SIZE get used in access_ok() ? > If so the repeated expansion of that 'mess' will slow things down. > > OTOH access_ok(ptr, len) can just check (ptr | (ptr + len)) < 0) > and rely on the page faults for everything else. Or do you want to discuss the bad side effect of is_compat_task()? Yes, test_thread_flag(TIF_32BIT) would slow down access_ok(). But if we use TASK_SIZE_MAX, VA_BITS still needs pgtable_l5_enabled, pgtable_l4_enabled detectation for riscv. It's not only for compat mode, but also Sv39, Sv48, Sv57. All treat TASK_SIZE_MAX as 0x8000000000000000, right? Then: access_ok(ptr, len) can just check (ptr | (ptr + len)) < 0) It's another feature and does not relate to compat mode. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1= 1PT, UK > Registration No: 1397386 (Wales) --=20 Best Regards Guo Ren