From patchwork Mon Nov 5 16:55:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jordan X-Patchwork-Id: 10668663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0843114E2 for ; Mon, 5 Nov 2018 16:56:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E79AB293D9 for ; Mon, 5 Nov 2018 16:56:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D96252946D; Mon, 5 Nov 2018 16:56:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70EE9293D9 for ; Mon, 5 Nov 2018 16:56:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 735AC6B0271; Mon, 5 Nov 2018 11:56:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 70ECB6B0272; Mon, 5 Nov 2018 11:56:40 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 569B46B0273; Mon, 5 Nov 2018 11:56:40 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id 1E62B6B0271 for ; Mon, 5 Nov 2018 11:56:40 -0500 (EST) Received: by mail-yw1-f69.google.com with SMTP id b76-v6so7749931ywb.11 for ; Mon, 05 Nov 2018 08:56:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=a2OiRCY8BwYFe4eDIMRKDWwH3Sf4ADRCu0KAZGhXWg0=; b=d2OdKgdg7Nj9Ye5IsNzWT0rK/6oMyJz+ooGqayu36wzQtWZ80+czcsJ59Vc18CsagL olfL9WQnEVDfLdozimuQk/qiM5hRi/y6cY6bF0BkUeE1cuKdyAonwb+ddzpKPMqG6VRV 8nw9phXueNQcb8QPl0VW4zgwBF5TsTlLACxSMKYFSL6spGKolbQOWVLQqPkeEK6LyM0H 32zxj+uH9dTASjarOdMcTUFFjbuLlGDTukaQvo1oyk70lQrlkha1oQa7K9tImAnNYHeW Ms5R51N5c/BrLNwLP2GWxoOLl/VpOjqHL+pp4qNh8atb2SrxqpOvpjJj0mlsKpDBioDx diyA== X-Gm-Message-State: AGRZ1gKASRjRy8ahx9+qgsiK0UhiJJbz5Va1idB6TRUzp5/yK88BufyO IMarLDnfPlrHp4QxOBUaY0Fop/febx/6kWSwSvrpW+P566lccFGxahHPM3hMnaa+7t/a0xMPUbZ Y9O62Kgy14bnUjHZeHT75JLtPTIF+dzQGH/zJrmRSsZLwam4CeCJGQ+fyXPOIDuBfcA== X-Received: by 2002:a0d:cb87:: with SMTP id n129-v6mr20767866ywd.213.1541436999856; Mon, 05 Nov 2018 08:56:39 -0800 (PST) X-Google-Smtp-Source: AJdET5eS51uYXaht3X6BQpicDi/GC5OSv63GD/+96sVBwDQ+8sXdGgCxbRXUxYro3jP9BhTK8vwj X-Received: by 2002:a0d:cb87:: with SMTP id n129-v6mr20767833ywd.213.1541436999219; Mon, 05 Nov 2018 08:56:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541436999; cv=none; d=google.com; s=arc-20160816; b=NDumnl8KU5lsQwwdOWNFahBnh0hnB/65rHhu0+8IvpkZWS3GeBSz8arqInl4PaxD7w 5YBHZpDKBnv2aYR2xtJme/a9fC7wFhJoBPtt6tRmjzLrcQmeIpXl4GJ2D6hGCR5qicNE hnjbNBBjlWJ8ZaUlMJG6SpUrTjX8b8lyozZ5dxDEIHtL6GDqQL/dU7UhvJiM1gSKifiz 3rS2h0DfcM00VPBzm37cOtqM9zpyze2iQQZvXkz59gbDFZhRIFt+M1hTj8sfGKyEIY9l lXkcMGiJ5KCyJjj87EMGuspu39xBT4brUdJuRaRFkVJkqizPcDFVe81ecR/Z/19qYLSH DzoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=a2OiRCY8BwYFe4eDIMRKDWwH3Sf4ADRCu0KAZGhXWg0=; b=wMnFH1xk2979OJPea8mEeThdfeC7DbPflkZ+XxlJbGVY4bGr2eRc20YQC+2B0oHfH+ 2/BXvVPegddFh65Z1tg1qCnjarjYeLB/fheg5ykQQ/UUQKCUQDJj8WQ01L5/N4AKMOqR ri3wsViElU3YTF8PxTuRDKLrvJfLmN+WAidJaiwPYJ3C1ZKEa6QS+trm+shH7sKMdD7E qhttwKTlYDxpxmwPkAZoDDy9jlqliiQaaTvEfyMDoPoRoZmEnlDEPEmXimSY0it1jCAX AiX6wJJd97/wnf7S546UGtVWgXl1z9YVvQoG5RH1crt3cUJTFYvCzW1PTLzdh3FHulF6 4Ofw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=KAhi1q2w; spf=pass (google.com: domain of daniel.m.jordan@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=daniel.m.jordan@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id r7-v6si25689731ywd.74.2018.11.05.08.56.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 08:56:39 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.m.jordan@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=KAhi1q2w; spf=pass (google.com: domain of daniel.m.jordan@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=daniel.m.jordan@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA5Gs0qK097046; Mon, 5 Nov 2018 16:56:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=a2OiRCY8BwYFe4eDIMRKDWwH3Sf4ADRCu0KAZGhXWg0=; b=KAhi1q2wPZLA+lEK3/3KyAFRrNkzLqmyxyDpGjQBIRkQwSlyk2/8oO9cw6hBVtplTD0Y Fr8lywyV+UoD7H5NFj17FJ42jAJbGq2lg05a59C8u/REeu+F4N7MwoFCUpeubJBVUKYX 4N7PDIBXJBmuJNPIuWdfFC39Cj+QCYHBlaGg/AFPGU+mJgSMkbb/ll62cYJUFdZ5JoYJ Ui41GCe9B+4kFzh7uMqR7qSdRd4dxCpKg+h9km1Z3MJ1Mdzmd1KfAzxCf3ax3bMAWOYy IkW/pkXENgdYH1+GwlT+AYH1b0Tq+o1epsWlUIMJJdcANSEpQiigwKPy+wUK55U6482m Ag== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2nh33tr6bp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 05 Nov 2018 16:56:24 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA5GuOXj025118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Nov 2018 16:56:24 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA5GuNaR008457; Mon, 5 Nov 2018 16:56:23 GMT Received: from localhost.localdomain (/73.60.114.248) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Nov 2018 08:56:23 -0800 From: Daniel Jordan To: linux-mm@kvack.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: aarcange@redhat.com, aaron.lu@intel.com, akpm@linux-foundation.org, alex.williamson@redhat.com, bsd@redhat.com, daniel.m.jordan@oracle.com, darrick.wong@oracle.com, dave.hansen@linux.intel.com, jgg@mellanox.com, jwadams@google.com, jiangshanlai@gmail.com, mhocko@kernel.org, mike.kravetz@oracle.com, Pavel.Tatashin@microsoft.com, prasad.singamsetty@oracle.com, rdunlap@infradead.org, steven.sistare@oracle.com, tim.c.chen@intel.com, tj@kernel.org, vbabka@suse.cz Subject: [RFC PATCH v4 10/13] mm: enlarge type of offset argument in mem_map_offset and mem_map_next Date: Mon, 5 Nov 2018 11:55:55 -0500 Message-Id: <20181105165558.11698-11-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181105165558.11698-1-daniel.m.jordan@oracle.com> References: <20181105165558.11698-1-daniel.m.jordan@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9068 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=778 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811050153 X-Bogosity: Ham, tests=bogofilter, spamicity=0.014894, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Changes the type of 'offset' from int to unsigned long in both mem_map_offset and mem_map_next. This facilitates ktask's use of mem_map_next with its unsigned long types to avoid silent truncation when these unsigned longs are passed as ints. It also fixes the preexisting truncation of 'offset' from unsigned long to int by the sole caller of mem_map_offset, follow_hugetlb_page. Signed-off-by: Daniel Jordan --- mm/internal.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 3b1ec1412fd2..cc90de4d4e01 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -367,7 +367,8 @@ static inline void mlock_migrate_page(struct page *new, struct page *old) { } * the maximally aligned gigantic page 'base'. Handle any discontiguity * in the mem_map at MAX_ORDER_NR_PAGES boundaries. */ -static inline struct page *mem_map_offset(struct page *base, int offset) +static inline struct page *mem_map_offset(struct page *base, + unsigned long offset) { if (unlikely(offset >= MAX_ORDER_NR_PAGES)) return nth_page(base, offset); @@ -378,8 +379,8 @@ static inline struct page *mem_map_offset(struct page *base, int offset) * Iterator over all subpages within the maximally aligned gigantic * page 'base'. Handle any discontiguity in the mem_map. */ -static inline struct page *mem_map_next(struct page *iter, - struct page *base, int offset) +static inline struct page *mem_map_next(struct page *iter, struct page *base, + unsigned long offset) { if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) { unsigned long pfn = page_to_pfn(base) + offset;