Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp548933rwl; Thu, 5 Jan 2023 00:48:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXvBIo8BxTMtYtz/nGKTVZmg+4hexuV+RwMB+batyj7SZnd3enM0imsSWGeRBfF3SpWM18Cz X-Received: by 2002:a17:90b:4a8c:b0:225:a8f2:fa38 with SMTP id lp12-20020a17090b4a8c00b00225a8f2fa38mr50323510pjb.21.1672908479825; Thu, 05 Jan 2023 00:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672908479; cv=none; d=google.com; s=arc-20160816; b=oIGBxIDYtJEIQ5EeX+SHsg6iMcYITI6nwjiMVD+VRYvFdnA2eOmK2QfjsxE8sZNnXT BvF7bS0AZDFKbalysjW2stVXZd+Y++gwyam9uQvozTU2r0AtE93T9Tb6Eiw5UXRoHvyH 4rYI2ci6UQIWw2x59EpnM+cVMfO3vsKHGNwbFfctUcVrnF3R434FVp7Yk1D75hUlKeV/ Z8HAIPSnAx6IHzTsflw4VUV7DBI9BSCWh6Nua5cljgKmCAbWNz0o6RaLjwgOzzcUWOr5 9AiIDgkaHZ+4uj7wIe0S5LLtEitRczZS49a3rg0J9YsxmcdAFch0Zz1+eIoCScoWP4mK I32A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=hCck/51gXT4nv/4OrHFUzHugnf6njmYJQeakPI93ooE=; b=OCXsvvQkCDJIZxN+SXa8SZFSp2rhm+Fzk0Dh96zg72diGW2hLUsGkA7yH4btY6AHpy o32C9bVsOTlwjNKo+lNG91Ndk3AzMqgpxsYmwNqE8yevJujrmLpKs2FnMSZBpPKblEok KPOBjDRqdsBi6oQIu42n8X7hrhRyR+mb4Rd2OQT565Ah+S/Jsf89ANg617rJ88cQyrDg dEGRreCXx3tLyU7MsFLtoI5JTq4Zq4fISMVgwRIfCBIgcKOIJwFfiYSH9+s0dZjvsw35 UdxdrqWqAIhfHtB2NJ08+dMo9wz0Rw0fZJiiawpF5QEqw899C9RwfMjAbmW3Er0V8KYG aWag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jq7GO2hD; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb7-20020a17090b4a4700b002265fe84432si1499488pjb.44.2023.01.05.00.47.51; Thu, 05 Jan 2023 00:47:59 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=Jq7GO2hD; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbjAEIpM (ORCPT + 57 others); Thu, 5 Jan 2023 03:45:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231344AbjAEIpK (ORCPT ); Thu, 5 Jan 2023 03:45:10 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30C164C71D for ; Thu, 5 Jan 2023 00:44:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672908260; 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: in-reply-to:in-reply-to:references:references; bh=hCck/51gXT4nv/4OrHFUzHugnf6njmYJQeakPI93ooE=; b=Jq7GO2hD/H9Y8RF5rbFriQvF65EkCOcVf6Qm3nwChOFK/9sQo8lzJnRL0NoqfO15iS7aWg Udia48gLuhwOxcdkqeU/uHXaiF1QDCzzD2rbb3bE7Rv48AOjZmlyJl4SQeDCjd/7QqyDpR UKbeU+Np+K9dN33xQNUxQWvUPnvZBmI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-408-Xl97Sky0Nc6oDp832RnL0g-1; Thu, 05 Jan 2023 03:44:19 -0500 X-MC-Unique: Xl97Sky0Nc6oDp832RnL0g-1 Received: by mail-wm1-f72.google.com with SMTP id l17-20020a05600c1d1100b003d9a145366cso9270249wms.4 for ; Thu, 05 Jan 2023 00:44:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hCck/51gXT4nv/4OrHFUzHugnf6njmYJQeakPI93ooE=; b=o+/ySHKe/QoYslHZzATdmldxF3Uu5T8AyLGEIVx7RGdTW02EIBZD7hAwLvc/yU1gqE h+U3tQrHD5oB9IQDelqSoh/YcefxnpAWgcYOOxr2tZrzqpwoly99Y++uDDr3EehuYmd5 TH3OA5RnIhFMfgQu011CFW4ZeaCKIKzhZL8JKeWi44RKeHe3QfUGWUKRbCuJkddD82TB MTpmjifUuLBy8vFgzaUKVRkxy6VUC5SozVhVxGeT8GUDicEkvss/Yyj6O3Ajie0hTmhm s12+cvp+rtAmn6l1U/usJsCzrMta/gORGmdl2Rdq/9oDGUgyb7bSFus1MSnQqld0QGn9 jBqw== X-Gm-Message-State: AFqh2krxvwO3M/QZLk9pq7ZWKZtWUDt/98yof+OCZx3npQUGtx5IgI3g AY1+2Z+VwKN0wkGueTjulkLG4n2m/jDrxRXaAJA5QVaFYMB+vcO2N1u202kbKrfz9fXolHPlcD6 BUYchsQtT7uFgf1mZ0cb6fQyM X-Received: by 2002:a05:600c:3b8f:b0:3d0:480b:ac53 with SMTP id n15-20020a05600c3b8f00b003d0480bac53mr38466586wms.12.1672908257913; Thu, 05 Jan 2023 00:44:17 -0800 (PST) X-Received: by 2002:a05:600c:3b8f:b0:3d0:480b:ac53 with SMTP id n15-20020a05600c3b8f00b003d0480bac53mr38466567wms.12.1672908257677; Thu, 05 Jan 2023 00:44:17 -0800 (PST) Received: from ?IPV6:2003:cb:c707:6e00:ff02:ec7a:ded5:ec1e? (p200300cbc7076e00ff02ec7aded5ec1e.dip0.t-ipconnect.de. [2003:cb:c707:6e00:ff02:ec7a:ded5:ec1e]) by smtp.gmail.com with ESMTPSA id g19-20020a05600c4ed300b003d978f8f255sm2202586wmq.27.2023.01.05.00.44.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Jan 2023 00:44:17 -0800 (PST) Message-ID: Date: Thu, 5 Jan 2023 09:44:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH 2/3] mm/mprotect: Use long for page accountings and retval Content-Language: en-US To: Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Mike Kravetz , Muchun Song , Nadav Amit , Andrea Arcangeli , James Houghton , Axel Rasmussen , Andrew Morton References: <20230104225207.1066932-1-peterx@redhat.com> <20230104225207.1066932-3-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230104225207.1066932-3-peterx@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On 04.01.23 23:52, Peter Xu wrote: > Switch to use type "long" for page accountings and retval across the whole > procedure of change_protection(). > > The change should have shrinked the possible maximum page number to be half > comparing to previous (ULONG_MAX / 2), but it shouldn't overflow on any > system either because the maximum possible pages touched by change > protection should be ULONG_MAX / PAGE_SIZE. Yeah, highly unlikely. > > Two reasons to switch from "unsigned long" to "long": > > 1. It suites better on count_vm_numa_events(), whose 2nd parameter takes > a long type. > > 2. It paves way for returning negative (error) values in the future. > > Currently the only caller that consumes this retval is change_prot_numa(), > where the unsigned long was converted to an int. Since at it, touching up > the numa code to also take a long, so it'll avoid any possible overflow too > during the int-size convertion. I'm wondering if we should just return the number of changed pages via a separate pointer and later using an int for returning errors -- when touching this interface already. Only who's actually interested in the number of pages would pass a pointer to an unsigned long (NUMA). And code that expects that there never ever are failures (mprotect, NUMA) could simply check for WARN_ON_ONCE(ret). I assume you evaluated that option as well, what was your conclusion? -- Thanks, David / dhildenb