From: Alexander Shishkin Subject: Re: [tip: perf/urgent] perf/aux: Fix tracking of auxiliary trace buffer allocation Date: Fri, 15 Nov 2019 18:06:59 +0200 Message-ID: <87bltddsyk.fsf@ashishki-desk.ger.corp.intel.com> References: <20191021083354.67868-1-tmricht@linux.ibm.com> <157165050422.29376.10692255781840811810.tip-bot2@tip-bot2> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <157165050422.29376.10692255781840811810.tip-bot2@tip-bot2> Sender: linux-kernel-owner@vger.kernel.org To: tip-bot2 for Thomas Richter , linux-tip-commits@vger.kernel.org Cc: Thomas Richter , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , Linus Torvalds , Mark Rutland , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , acme@kernel.org, gor@linux.ibm.com, hechaol@fb.com, heiko.carstens@de.ibm.com, linux-perf-users@vger.kernel.org, songliubraving@fb.com, Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com List-Id: linux-perf-users.vger.kernel.org "tip-bot2 for Thomas Richter" writes: > /* now it's safe to free the pages */ > - atomic_long_sub(rb->aux_nr_pages, &mmap_user->locked_vm); > - atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm); > + if (!rb->aux_mmap_locked) > + atomic_long_sub(rb->aux_nr_pages, &mmap_user->locked_vm); > + else > + atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm); This only works correctly when rb->aux_mmap_locked is either equal to rb->aux_nr_pages or zero. Otherwise, it leaks rb->aux_nr_pages - rb->aux_mmap_locked in the locked_vm permanently. Regards, -- Alex