Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7049012rwr; Tue, 2 May 2023 08:50:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7unhYLBiiSnSs0xRvtupds3nfUo3DA5C8rvPm0tnGS8X70fyjpmarB7KEtPQogpkoqLDNB X-Received: by 2002:a05:6a20:1592:b0:f6:592a:7e28 with SMTP id h18-20020a056a20159200b000f6592a7e28mr22568120pzj.14.1683042632229; Tue, 02 May 2023 08:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683042632; cv=none; d=google.com; s=arc-20160816; b=bj8LG/e29xIJR1mcsoByYkE3kziAHT6qijCmSXcOBQAGW49UWms3CXzwdbQHm3kU1m DOVO2qdznl9ME4smNWK1RLgcXp3OwFjTGaZf7DuEbQZ4tlOQZNDvYgsXB5xPExYRz1zk x/+4in+5RZqH4zflZFezVfQVEBiHnj7T05aziq/gJOvA5HtYQTa3M+qINXyW/+w47Llg hRV823zqWqtQJqxV6m9kvernWpMhvNuRpRcb11lHLanb0pL5Bs7dWIHuO07DHOKFPMrj vnDwQ9lnoILsuOR1uCoZI+5vfRKK0MsX4Wz39bsZNEjfTun8KR/zSqytYNdKenZl6ohr SQGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=fM6PWEfN8nk8BLRgar+pdo3PC8NxEDsWsTTRqjkuEow=; b=gvFdB6CoqXTAa+TdbXoKf9uXou+1x3YMiI4qFm06Ky7AWsU1vimTiWw7+l++e4G4gd uKnHD9Uzneqr1dKECWGzixw+bP6qiHfvAJLeOpsvzNw+0LdWjxKGY6MxDll0MoHspZTG kpYrWfRcgSMH7KkSXjltuW9t7gVP4yTaCWMOxmnbhAv7YJe/LW0XyGxYawBtpcYdZR/P 3G2f4Ag6Zp2dIzyYZNiOqQ0aMFLr3S3IJ3JM/zSN82eNGgWBw2G2mAXQWdvAciYYI9OW PAriwxBOmevNNPv2D5NMVLf4UBAiNoBBFItM1PvS2JIO5qqb2DbNaBZH6CmYJVz+0i3S l4Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZzTEapTo; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b005186ed361f4si29986628pgh.315.2023.05.02.08.50.15; Tue, 02 May 2023 08:50:32 -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=@intel.com header.s=Intel header.b=ZzTEapTo; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233856AbjEBPmw (ORCPT + 99 others); Tue, 2 May 2023 11:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbjEBPmv (ORCPT ); Tue, 2 May 2023 11:42:51 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26B521A6 for ; Tue, 2 May 2023 08:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683042170; x=1714578170; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to; bh=s53ckWSCPCD27YqdcQdt7WZr3VrH45zL/WyjwkVkJsY=; b=ZzTEapToq4Xf83IU6V++A/408o2XaF2DxQP5Sdy5pHs/NCjxvlCwa3Vk ibggqqq/XsCTNxfyBIMkNYWlSM4CrNr02ATIHcH6510O1XxDaMcjpAs9E C3GhYUHOnlRetGOvXIB2S9Is3oW3E9FvRVj2oCx1mYJX6Zoo6ejFBk1UI bI933bHOy6/dtFDvGzY8v1R7Y4PH+wYctbU+XgM63eJeh4/JSnhrBjiyk Tl/l9WfVMIynjkoLY7kxO4Wni5JdOXnWXoG3kQV8fSx82LlZuWdNb/QU0 GGHVDgHKJEvhk0rZI0v6bNsQgF1UtB5PmsjypWV/w8Ukx9RPwRP6YIkWz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10698"; a="413891000" X-IronPort-AV: E=Sophos;i="5.99,244,1677571200"; d="scan'208";a="413891000" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2023 08:42:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10698"; a="673700928" X-IronPort-AV: E=Sophos;i="5.99,244,1677571200"; d="scan'208";a="673700928" Received: from vsanka-mobl.amr.corp.intel.com (HELO [10.212.168.155]) ([10.212.168.155]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2023 08:42:49 -0700 Content-Type: multipart/mixed; boundary="------------Ze0LFxpBo0szqDF8dkE4MQ9Q" Message-ID: <641a9348-a052-6bb5-e6c7-64acb6405328@intel.com> Date: Tue, 2 May 2023 08:42:48 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [GIT PULL] x86/mm for 6.4 Content-Language: en-US To: "Kirill A. Shutemov" , Linus Torvalds Cc: Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, Peter Zijlstra References: <20230427225647.1101172-1-dave.hansen@linux.intel.com> <20230429003822.n3mglslg666j3npp@box.shutemov.name> From: Dave Hansen In-Reply-To: <20230429003822.n3mglslg666j3npp@box.shutemov.name> X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------Ze0LFxpBo0szqDF8dkE4MQ9Q Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/28/23 17:38, Kirill A. Shutemov wrote: > BTW, I think the static check can be relaxed. Checking size against > PAGE_SIZE is rather conservative: there's 8 TB (or 4 PB for 5-level > paging) guard hole at the begging of kernel address space. Whatever we relax it to, let's make sure we get a note in Documentation/x86/x86_64/mm.rst. But that's totally minor and we can fix it up later. Have anyone seen any actual code generation difference between: return (long)ptr >= 0; and return !((unsigned long)ptr & (1UL<<(BITS_PER_LONG-1))); ? I'm seeing gcc generate the same code for both the <=PAGE_SIZE side and the 'sum' side. It's longer, but I'd rather read the explicit "check bit 63" than the positive/negative address space thing. I certainly grok both, but have to think through the "(long)ptr >= 0" check every time. I guess it also wouldn't matter as much either if we hid it in a helper like the attached patch and I didn't have to read it twice. ;) --------------Ze0LFxpBo0szqDF8dkE4MQ9Q Content-Type: text/x-patch; charset=UTF-8; name="ptr_in_user_half.patch" Content-Disposition: attachment; filename="ptr_in_user_half.patch" Content-Transfer-Encoding: base64 ZGlmZiAtL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