From patchwork Fri Nov 5 20:38:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12605503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E061C433F5 for ; Fri, 5 Nov 2021 20:38:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D562F6056B for ; Fri, 5 Nov 2021 20:38:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D562F6056B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6F957940042; Fri, 5 Nov 2021 16:38:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65B3394003D; Fri, 5 Nov 2021 16:38:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ACF2940042; Fri, 5 Nov 2021 16:38:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 3495494003D for ; Fri, 5 Nov 2021 16:38:20 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id EF28B1802EFDD for ; Fri, 5 Nov 2021 20:38:19 +0000 (UTC) X-FDA: 78776039160.17.854C555 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf16.hostedemail.com (Postfix) with ESMTP id 68CA5F000097 for ; Fri, 5 Nov 2021 20:38:11 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id B2179611C0; Fri, 5 Nov 2021 20:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1636144698; bh=ATPv8/v4Nqm+039u6nxvoHetifbhpBxKrXQN0Sbsr2o=; h=Date:From:To:Subject:In-Reply-To:From; b=lIY8ZrQVk5rqK+ZedOqf+z2Qqp16S4s4W1wkwqumB89hebWjVxiOuntTWMNqZn5JJ 3K2LcxA0cSefESaJlajGzp0naUwMjOmAZN8TbvxuLU4x/6rg57AolreHVs4AlNV7vc VDMs14ulayNxgSN/O/zBaZWR1vUcDbMWkXnP85Ic= Date: Fri, 05 Nov 2021 13:38:18 -0700 From: Andrew Morton To: akpm@linux-foundation.org, amit.kachhap@arm.com, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, Vincenzo.Frascino@arm.com Subject: [patch 070/262] mm/memory.c: avoid unnecessary kernel/user pointer conversion Message-ID: <20211105203818.RLrQbH0Iv%akpm@linux-foundation.org> In-Reply-To: <20211105133408.cccbb98b71a77d5e8430aba1@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=lIY8ZrQV; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 68CA5F000097 X-Stat-Signature: 88mr9pa6snhbqxcpskf3nifz4ho94ckd X-HE-Tag: 1636144691-890923 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: From: Amit Daniel Kachhap Subject: mm/memory.c: avoid unnecessary kernel/user pointer conversion Annotating a pointer from __user to kernel and then back again might confuse sparse. In copy_huge_page_from_user() it can be avoided by removing the intermediate variable since it is never used. Link: https://lkml.kernel.org/r/20210914150820.19326-1-amit.kachhap@arm.com Signed-off-by: Amit Daniel Kachhap Acked-by: Kirill A. Shutemov Cc: Vincenzo Frascino Signed-off-by: Andrew Morton --- mm/memory.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/mm/memory.c~mm-memory-avoid-unnecessary-kernel-user-pointer-conversion +++ a/mm/memory.c @@ -5421,7 +5421,6 @@ long copy_huge_page_from_user(struct pag unsigned int pages_per_huge_page, bool allow_pagefault) { - void *src = (void *)usr_src; void *page_kaddr; unsigned long i, rc = 0; unsigned long ret_val = pages_per_huge_page * PAGE_SIZE; @@ -5434,8 +5433,7 @@ long copy_huge_page_from_user(struct pag else page_kaddr = kmap_atomic(subpage); rc = copy_from_user(page_kaddr, - (const void __user *)(src + i * PAGE_SIZE), - PAGE_SIZE); + usr_src + i * PAGE_SIZE, PAGE_SIZE); if (allow_pagefault) kunmap(subpage); else