From patchwork Fri Sep 21 09:50:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yue Haibing X-Patchwork-Id: 10609537 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 3EDB4157B for ; Fri, 21 Sep 2018 09:50:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D75D2DC9B for ; Fri, 21 Sep 2018 09:50:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F9992DCA0; Fri, 21 Sep 2018 09:50:55 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 93E1B2DC9B for ; Fri, 21 Sep 2018 09:50:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 461AF8E0003; Fri, 21 Sep 2018 05:50:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3C19D8E0001; Fri, 21 Sep 2018 05:50:53 -0400 (EDT) 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 23D858E0003; Fri, 21 Sep 2018 05:50:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id E26448E0001 for ; Fri, 21 Sep 2018 05:50:52 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id h4-v6so5932040pls.17 for ; Fri, 21 Sep 2018 02:50:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version; bh=tA34fLE43HJmSTCD9soj8htyGW9vfIL6SLg+5Pfz2so=; b=HDQNYJtbOyVJXuI27YSlp6+UIBv6g/HFRq6xoJSAfPoBFhGkIWGk5Dll3bCXwp+BLz mVsMUsxItdnERHlOHl2Qqvoo7BfYwV2l7Qc0R07nJHjEom4Afzd0M1/XKf3QzTymJ4HI Y8PsoHeH3/3NFC50TxvX/JUNHbteOr9AiCOiphQicA1j1OFhMLprlEm7yt0W8wUxr8Jy Mmq2qk4bs3PBKJQuacZaXWtJu62VtSHRL0tVi8PuY/3zWtgckCTeobrr2swvqI2KXxZc aoWesKSEp7sBukIKiB/5LXkIB0DlEvkPD9pTYbWQsy/dCxRVPL26M2R7MNjnGuexhZTS KfbQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yuehaibing@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yuehaibing@huawei.com X-Gm-Message-State: APzg51BKubKVdbN+Y+dkxzkhcRbdTI8LXQZJT8h5eOKAtEXuQZNdBsiE 1vGSox6sIchoPCeGs9RgHsvp+hBI/ISn/nm8TZx8MudUCUIbgf0zsmZdtABSc80R3bIVRyoU+Vk XJ1mGl6I4S+xqyTO2yDKEfmY5tK/qAn/ts6O6luUwpGAzKrbAhSyrddmaTbok32TFjw== X-Received: by 2002:a62:464f:: with SMTP id t76-v6mr45637525pfa.118.1537523452487; Fri, 21 Sep 2018 02:50:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZsw/BG34Mxyv1nvdY7wERJQC2FyIKBYtGXVKW+oHdjPD12mQ1QeEgayxpgnG5PMKxElyLI X-Received: by 2002:a62:464f:: with SMTP id t76-v6mr45637471pfa.118.1537523451676; Fri, 21 Sep 2018 02:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537523451; cv=none; d=google.com; s=arc-20160816; b=AABeRRf6t5Ko8JQvO5YMHC241knAkBUzXWj2Odo7ifnGLOAiXO+s42sM5YPlzq+Hza X2I3wHtyMrZrlNkCnlqPgy5K0aUyEmp7+GFOoALwxJlRKjGTL/gIRoWTQIIbo3VugmHz t8M4AJ7yzP8898CxWyxv6futFus718Z0qg4BPmqpvF7NI+kQRGvYmoh930shi2AZF+BD tkSAcUskIwiwomoTrVt0+OpgEP+2DFM2xVGda8j2z9iRUr4GMGitkxd5ko2jeS7HRTao l4B1z4YJbHHMYbTdW0vi4udHefCkwT8Kj4PPgiZHNQVjx5Uo8YdmwKmhTyxFZ3CmygFW HjNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:subject:cc:to:from; bh=tA34fLE43HJmSTCD9soj8htyGW9vfIL6SLg+5Pfz2so=; b=iKD95x3N1uLOsWQWG53FEq7AkfZ9a/FPAv7MWhcYoXx3aeK3C7koOdcXX7M17ZeiUR CHfxTkrXLZfBooDp1kr1dfziZgn7itGVoXCXGfwZo/7CIMG8FmL91WQtn0ioIBG3T+NL R8Of+HL8H7Hn0ofT8NJeTZ5/XXiAZnR+4TOzMtKCLKVX74FGH+3O+xPBgOzpnun8FdYM VpmxCDS5609RlbxOxMv1gfxq1Z05oac8bE9zyddh46Qx4bU2I/nQc6PNgtApVfdNUIhh YcW+Dk8o4mm8LaW4vDIla3IqCbKZJBD6HHZIz7CpkiEu1GjisoXfzZhrFgCboRUZCaMU NUZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yuehaibing@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yuehaibing@huawei.com Received: from huawei.com (szxga07-in.huawei.com. [45.249.212.35]) by mx.google.com with ESMTPS id cf16-v6si28489724plb.254.2018.09.21.02.50.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 02:50:51 -0700 (PDT) Received-SPF: pass (google.com: domain of yuehaibing@huawei.com designates 45.249.212.35 as permitted sender) client-ip=45.249.212.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yuehaibing@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=yuehaibing@huawei.com Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 71553441F4130; Fri, 21 Sep 2018 17:50:48 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Fri, 21 Sep 2018 17:50:41 +0800 From: YueHaibing To: , , , CC: , , YueHaibing Subject: [PATCH -next] mm/gup_benchmark: Fix unsigned comparison to zero in __gup_benchmark_ioctl Date: Fri, 21 Sep 2018 17:50:15 +0800 Message-ID: <20180921095015.26088-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 get_user_pages_fast will return negative value if no pages were pinned, then be converted to a unsigned, which is compared to zero, giving the wrong result. Fixes: 09e35a4a1ca8 ("mm/gup_benchmark: handle gup failures") Signed-off-by: YueHaibing --- mm/gup_benchmark.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c index 6a47370..7405c9d8 100644 --- a/mm/gup_benchmark.c +++ b/mm/gup_benchmark.c @@ -19,7 +19,8 @@ static int __gup_benchmark_ioctl(unsigned int cmd, struct gup_benchmark *gup) { ktime_t start_time, end_time; - unsigned long i, nr, nr_pages, addr, next; + unsigned long i, nr_pages, addr, next; + int nr; struct page **pages; nr_pages = gup->size / PAGE_SIZE;