Received: by 10.213.65.68 with SMTP id h4csp1115149imn; Wed, 14 Mar 2018 10:01:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELt8LNJartKvqzYwOuDk2zDn//1Hv1e/mm26wY1a3hwerowE5+nFZOgRwgY/pnr7lnbxv3if X-Received: by 10.101.83.3 with SMTP id m3mr4216751pgq.197.1521046913273; Wed, 14 Mar 2018 10:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046913; cv=none; d=google.com; s=arc-20160816; b=T/+4I6wnLzIRmfRl6gTxgaYS6UU0w8yh2zr0gxk/fpFNcB6PwvDk/I6QNLdGqEIzgU ip3OJJYn5EMDZgEFLH7U9ciq1N8qh0BaXIcP7Pvww+Xp1XX7XwjDFFv2U3m1YBB67rCd NvBDCyJAWWl3POzPeLavfY0yM9APza7cworwUDQFaVC7wyinC+2PCkj+E9/g/yYiRsta 1qoTXaQfuqtq25uHqwZfgL5O88fRMqFXeB6RKqeo2g1NZs9nYhMlB1SJ29ALoISWYhEZ BVvOTvRxT70SLL+MSMtd4fMgS56JJUucXMn+KG7jIefQTMY7WfEh9I1Pv09kjkcFVXHy vPsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=fd7p1NL0ey9DoeCT5PnHLDV/IHyyTrP+nt2/gpIiCjE=; b=pZOt0watwHckb9r8Hr0tT7CeixVujWvYWYia4QDTwheMk88+JP3sm1eehDN2xoHMpm lFSqQxyZLmuqQRaq7c2C3pNQiekzaGSBjXE4WcjLF63+L6XRSh2w6K1CVSTZcAfEr0b2 J892Bymxkgtgrj7G2PA5iK/m+6O2J8CSVyVrMaoadMBnuU03jaX/380bbXxs90WHTtai hO3dYIX6QFIAjcZXH+Rw6XlUeaxnIs48AsTMD/u3QSxRaWmbpdzFlNvn+OWrjky+RiaK XDMNVVCd//fVfmyXIQLHOZ0UIcfqa9v4cHz7GtfOQ/Vbs/QUyz3YUG+wpqjW0LuRsX85 ejwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay2-v6si2191173plb.749.2018.03.14.10.01.29; Wed, 14 Mar 2018 10:01:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752409AbeCNQ77 (ORCPT + 99 others); Wed, 14 Mar 2018 12:59:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56104 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932282AbeCNQ7v (ORCPT ); Wed, 14 Mar 2018 12:59:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 962208424D; Wed, 14 Mar 2018 16:59:50 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id BFCB12026DFD; Wed, 14 Mar 2018 16:59:44 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 14 Mar 2018 17:59:50 +0100 (CET) Date: Wed, 14 Mar 2018 17:59:44 +0100 From: Oleg Nesterov To: Ravi Bangoria Cc: mhiramat@kernel.org, peterz@infradead.org, srikar@linux.vnet.ibm.com, acme@kernel.org, ananth@linux.vnet.ibm.com, akpm@linux-foundation.org, alexander.shishkin@linux.intel.com, alexis.berlemont@gmail.com, corbet@lwn.net, dan.j.williams@intel.com, gregkh@linuxfoundation.org, huawei.libin@huawei.com, hughd@google.com, jack@suse.cz, jglisse@redhat.com, jolsa@redhat.com, kan.liang@intel.com, kirill.shutemov@linux.intel.com, kjlx@templeofstupid.com, kstewart@linuxfoundation.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, milian.wolff@kdab.com, mingo@redhat.com, namhyung@kernel.org, naveen.n.rao@linux.vnet.ibm.com, pc@us.ibm.com, pombredanne@nexb.com, rostedt@goodmis.org, tglx@linutronix.de, tmricht@linux.vnet.ibm.com, willy@infradead.org, yao.jin@linux.intel.com, fengguang.wu@intel.com Subject: Re: [PATCH 5/8] trace_uprobe: Support SDT markers having reference count (semaphore) Message-ID: <20180314165943.GA5948@redhat.com> References: <20180313125603.19819-1-ravi.bangoria@linux.vnet.ibm.com> <20180313125603.19819-6-ravi.bangoria@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180313125603.19819-6-ravi.bangoria@linux.vnet.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 14 Mar 2018 16:59:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 14 Mar 2018 16:59:50 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'oleg@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/13, Ravi Bangoria wrote: > > +static bool sdt_valid_vma(struct trace_uprobe *tu, struct vm_area_struct *vma) > +{ > + unsigned long vaddr = vma_offset_to_vaddr(vma, tu->ref_ctr_offset); > + > + return tu->ref_ctr_offset && > + vma->vm_file && > + file_inode(vma->vm_file) == tu->inode && > + vma->vm_flags & VM_WRITE && > + vma->vm_start <= vaddr && > + vma->vm_end > vaddr; > +} Perhaps in this case a simple ref_ctr_offset < vma->vm_end - vma->vm_start check without vma_offset_to_vaddr() makes more sense, but I won't insist. > +static void sdt_increment_ref_ctr(struct trace_uprobe *tu) > +{ > + struct uprobe_map_info *info; > + struct vm_area_struct *vma; > + unsigned long vaddr; > + > + uprobe_start_dup_mmap(); > + info = uprobe_build_map_info(tu->inode->i_mapping, > + tu->ref_ctr_offset, false); Hmm. This doesn't look right. If you need to find all mappings (and avoid the races with fork/dup_mmap) you need to take this semaphore for writing, uprobe_start_dup_mmap() can't help. Oleg.