Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1247140ima; Wed, 24 Oct 2018 17:39:23 -0700 (PDT) X-Google-Smtp-Source: AJdET5c+QnMfWbS4QAF8k4/OYsicCCgr5z3GdcICwW6RBPeg6eeHMguumEMBc/lNtnNiQ3nzYCSA X-Received: by 2002:a17:902:9a44:: with SMTP id x4-v6mr4426560plv.121.1540427963769; Wed, 24 Oct 2018 17:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540427963; cv=none; d=google.com; s=arc-20160816; b=P5qx2Ob/58f12bMylHSw2QtiakMBUi1Wzwc9LCmE3SYWDrUGo1KK5du+BP9sZTQECh 2T0JZLEFmjSqrEn4AtDa03qlgttFu5k/BnuLb/dIPNRLeJqjw6EbIFwGC8WDME0Asahn 3eYlUlndbvAbOzGTnSg7W4YSGmZa21f60iTHkN6xkuYksLFD5SPhECw1enSXjS0nRmkE 4E13cYpJyeGtZ9tSOcZa9s5StAq3Gj/YO8MvJykgWx78JP3gkmvazdqHTjfG58tqXlLw LqNboxBbSBBAIeW/Av9agkiNFGyjl/dRyZ63DpUBwephcur+++FhXY5fD8QK3rp9krXb Te2w== 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:dkim-signature; bh=/V82UfchjbRn+jVT094fp0cw8ZiNYcEUP5bvpPy/uFE=; b=uaC3xhtidgVCiT5lYMsvDUg+FbCIg82lOjwgjGSGbBfPdU3q9fAiYFubslISNFZ1xm D5tG8AgDIWLzisICluv4cwvtkWYjMqeN7jglntKUOtVWa7inHEf/Ziu01sSV8rpxkByV IXEbjXUQoMz6Wktduv6jHeWoywZXteh2rnevU+SKcwefO7GGNRcU5+TI+5lIVy6oFjtQ VxgNb3oPouZG4+LmdFjDhcrXJrOrxyIuWriOzEKjDcU03RV5WadBLUWItDGos/a/a7Q1 +bIEeGDuGSR4EyrigVlSrLfDbZ23B7k9f+tTQ/vKeHrXs78AF/mR1mzSFndsA1TJ9UEm K43A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="SjcDa/Dc"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14-v6si6119242pgr.259.2018.10.24.17.39.07; Wed, 24 Oct 2018 17:39:23 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="SjcDa/Dc"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726443AbeJYJHB (ORCPT + 99 others); Thu, 25 Oct 2018 05:07:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:42104 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbeJYJHB (ORCPT ); Thu, 25 Oct 2018 05:07:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/V82UfchjbRn+jVT094fp0cw8ZiNYcEUP5bvpPy/uFE=; b=SjcDa/DcpbS2n7zHc1S51O9on 0X15V9hxqPjWFFpokJB47cE9084Cvkdv2/Nvsik6BHNjNQreskEFnmpiauu3mKQrVsgeqkxPiHgFJ vCsmmD+Pi+WFQiEKo06AFp/gDjYlqJoDBERngcs1wFcSHrYM0uWYfP/571Q2lpLDOS3YFKMqvBMvN jebJ8eDd+ioIJQPZKcrYy14NmQwBoOgwajOuh9DVdLsJeSuSwlmQZRe7UzPMjfSCRF+IPD4dJd27a 1K05p/vRiVTq1XoiPacMaI5JHZtfXeCM9BIUMwkQqLrX22uE1VE4A6bt8Aro1tbAA+AcMM7OMexVx HOHG+RAig==; Received: from [167.98.65.38] (helo=worktop) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gFTdY-0002UX-Di; Thu, 25 Oct 2018 00:36:37 +0000 Received: by worktop (Postfix, from userid 1000) id C28896E0675; Thu, 25 Oct 2018 02:29:43 +0200 (CEST) Date: Thu, 25 Oct 2018 02:29:43 +0200 From: Peter Zijlstra To: kan.liang@linux.intel.com Cc: tglx@linutronix.de, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, bp@alien8.de, ak@linux.intel.com, eranian@google.com Subject: Re: [PATCH 1/2] perf: Add munmap callback Message-ID: <20181025002943.GT3109@worktop.c.hoisthospitality.com> References: <20181024151116.30935-1-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181024151116.30935-1-kan.liang@linux.intel.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 24, 2018 at 08:11:15AM -0700, kan.liang@linux.intel.com wrote: > +void perf_event_munmap(void) > +{ > + struct perf_cpu_context *cpuctx; > + unsigned long flags; > + struct pmu *pmu; > + > + local_irq_save(flags); It is impossible to get here with IRQs already disabled. > + list_for_each_entry(cpuctx, this_cpu_ptr(&sched_cb_list), sched_cb_entry) { > + pmu = cpuctx->ctx.pmu; > + > + if (!pmu->munmap) > + continue; > + > + perf_ctx_lock(cpuctx, cpuctx->task_ctx); > + perf_pmu_disable(pmu); > + > + pmu->munmap(); > + > + perf_pmu_enable(pmu); > + > + perf_ctx_unlock(cpuctx, cpuctx->task_ctx); > + } > + local_irq_restore(flags); > +} > + > static void perf_event_switch(struct task_struct *task, > struct task_struct *next_prev, bool sched_in); > > diff --git a/mm/mmap.c b/mm/mmap.c > index 5f2b2b184c60..61978ad8c480 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -2777,6 +2777,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len, > /* > * Remove the vma's, and unmap the actual pages > */ > + perf_event_munmap(); I think that if you add the munmap hook, you should do it right and at least do it such that we can solve the other munmap problem. > detach_vmas_to_be_unmapped(mm, vma, prev, end); > unmap_region(mm, vma, prev, start, end); > > -- > 2.17.1 >