From patchwork Wed Sep 12 20:24:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prakash Sangappa X-Patchwork-Id: 10598301 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 C18B1112B for ; Wed, 12 Sep 2018 20:25:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B23B227C0B for ; Wed, 12 Sep 2018 20:25:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A68A52A7D5; Wed, 12 Sep 2018 20:25:11 +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 34BF827C0B for ; Wed, 12 Sep 2018 20:25:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C49358E0005; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B283D8E0001; Wed, 12 Sep 2018 16:25:05 -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 9C6FF8E0001; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it0-f69.google.com (mail-it0-f69.google.com [209.85.214.69]) by kanga.kvack.org (Postfix) with ESMTP id 70BBC8E0005 for ; Wed, 12 Sep 2018 16:25:05 -0400 (EDT) Received: by mail-it0-f69.google.com with SMTP id e62-v6so5429744itb.3 for ; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) 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; bh=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=hYjyTNWjDibK9V0T4iMt6Mgjzx7SAjLUrFwqE5jL2uqgCimIRXpBe5EijqRkuc7QKO ERLholUQMbCMWDlIxLz6HylNOKztKi7mamtO+iEWMZQeZfzjRX5BlwfF6oEIOrlfSJlM 6PKCpSv7lDNkOG0wmyiuMztqLkvBHTkZG8I69ydMSbpuZctIaytg9HFNlB1fMFXgkGaV m/DoFDMbnPzv8Ym19k689vzXohqYg0Z10a5l9zDgziflkVb1UAu9P3hcL0EvRNjpZ4jJ 3TXkK1BO3MDlep6usgTlOV4tYXJnH8sJ6HqPMmj9sR8kfdkX8mh+kMBJcKdTcidnIvTm oSdA== X-Gm-Message-State: APzg51Dzo89arf5zrcv4RVIpyKULSHyOyBtibZ8XwjUfYCEDJtevMYLU mY0sLWng9PWlje7nlokNaLa1oEKBA0s7fOR8krDUUUPE9vkjYLwzMcRPWVchkBQXy2kNsL5ga0c Zv/qUChjYfbmRxvA22MMQUHW+khfeSoreu0kXCiW+CEavimmssGaij4E10Zb7le9JzQ== X-Received: by 2002:a6b:dd18:: with SMTP id f24-v6mr3389911ioc.114.1536783905242; Wed, 12 Sep 2018 13:25:05 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda0+h9cFhhznyhhEvr/hNXwEoDzo3nQb34Rwx0w/rKzrD9flGWcZtebu9ssOhn5oSiiGqyk X-Received: by 2002:a6b:dd18:: with SMTP id f24-v6mr3389853ioc.114.1536783904275; Wed, 12 Sep 2018 13:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536783904; cv=none; d=google.com; s=arc-20160816; b=Uk8e6bJl9u10Tn7QeGiq0DmrAnLMqxUMvWF+zXoFqKqUp9/DsmF3J56MWTR56Al3UK be1m9C17QzMhqwv1ImGUEqY68L+o/hi4bN8H8WNcX1+lMz8U4G59N0CmX+204y2x3CdS Ri4AWOzP49CRg8+jrTJoB7L9Ebme3oA/RQ8qczK0td55oKAg24SROyANoZpzg/ijFXRn Hs/N4hlVILHRCcLA/Hn87UWs5/otlfiKR2k0VCuLKLRsXNtcmASfPW7vDx+hB1StL+gJ z/sBeyDVLPOoZrfaNbwx7dBbDi770jaUhwvpCHeQZk3Pek52kmmfZsTx6PR4br9U65et WZFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=ZZzeoxuQDr/Hw+M9hqVCp4Aj3GXkPAQuFBAW9gI42f3ce+YzF9/lOjkxNZagIbdn7A WqbfhiyMellDfCTIgt62SGfyM2UueioUPxOaB0vB9iELvqJ+vJMJmo3ZFBgQCtStX6mJ Zk0IYsFktrGabfwNQAdICM54If1xBOgXOpA0Mx1zAnzS15TlXtHrb7DiFoDt2RgvTq6P AYcF+P4P62ICaTJp7OBE/D8nmKyCqHu/Y943jCcbZFnElbuV5zOdSorxw1WR8qatfDon LO2ZGFBzyS5smUA4++JatTOgOLIiL9ZmI2ZMukIjwE8tGHKCaHLwpR3rgqr3PbYKQVZi YObQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=P1lIUvk9; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=prakash.sangappa@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id b62-v6si1616292iti.112.2018.09.12.13.25.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 13:25:04 -0700 (PDT) Received-SPF: pass (google.com: domain of prakash.sangappa@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=P1lIUvk9; spf=pass (google.com: domain of prakash.sangappa@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=prakash.sangappa@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8CKO6LB084494; Wed, 12 Sep 2018 20:25:01 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; s=corp-2018-07-02; bh=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=P1lIUvk9b+Z/DAZVGAy2Zf58rJ1fc5O1bxJqkp5l86Uc0CM5X4v21jIKSNLipOGBqshd biWb7mlxkIwrHdorzdJBioUjaNaKIU+21qiMGcdEl65xwyLSnq39HU8G/KKEy2AYcM7B 6mJAhGjUrZdm4YVp06HHbidHBWta8hiFrJad2lfAAMMDtjYpWTtIWEYxoVqLYp3Zkqi5 1e7JKJZeO6aXNPdbpuSo1WZCEopRzF+SN1Kozre9TrqpOgCHdeA6/dM9quUG8DqwDWoK Fl6DD2zsDapfAuBX4FeWVt0yIJSxiaU+mcIQ4hkDVQ4cMnF7y3M1R0WBFiBiiEqjonKT 6A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mc6cpvd7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:01 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOxuQ010208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:00 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8CKOxhK032107; Wed, 12 Sep 2018 20:24:59 GMT Received: from pp-ThinkCentre-M82.us.oracle.com (/10.132.93.61) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Sep 2018 13:24:59 -0700 From: Prakash Sangappa To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: dave.hansen@intel.com, mhocko@suse.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, khandual@linux.vnet.ibm.com, steven.sistare@oracle.com, prakash.sangappa@oracle.com Subject: [PATCH V2 4/6] Add support to lseek /proc//numa_vamaps file Date: Wed, 12 Sep 2018 13:24:02 -0700 Message-Id: <1536783844-4145-5-git-send-email-prakash.sangappa@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536783844-4145-1-git-send-email-prakash.sangappa@oracle.com> References: <1536783844-4145-1-git-send-email-prakash.sangappa@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9014 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120201 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 Allow lseeking to a process virtual address(VA), starting from where the address range to numa node information can be read. The lseek offset will be the process virtual address. Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- fs/proc/task_mmu.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 1371e379..93dce46 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1866,6 +1866,27 @@ static int gather_hole_info_vamap(unsigned long start, unsigned long end, return 0; } +static loff_t numa_vamaps_llseek(struct file *file, loff_t offset, int orig) +{ + struct numa_vamaps_private *nvm = file->private_data; + + if (orig == SEEK_CUR && offset < 0 && nvm->vm_start < -offset) + return -EINVAL; + + switch (orig) { + case SEEK_SET: + nvm->vm_start = offset & PAGE_MASK; + break; + case SEEK_CUR: + nvm->vm_start += offset; + nvm->vm_start = nvm->vm_start & PAGE_MASK; + break; + default: + return -EINVAL; + } + return nvm->vm_start; +} + static int vamap_vprintf(struct numa_vamaps_private *nvm, const char *f, ...) { va_list args; @@ -2052,7 +2073,7 @@ const struct file_operations proc_pid_numa_maps_operations = { const struct file_operations proc_numa_vamaps_operations = { .open = numa_vamaps_open, .read = numa_vamaps_read, - .llseek = noop_llseek, + .llseek = numa_vamaps_llseek, .release = numa_vamaps_release, }; #endif /* CONFIG_NUMA */