Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4662758ybc; Fri, 15 Nov 2019 08:08:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwkX7UI3b4foWV9WSmFpezCnF/+0SPnO37+T9lFs9ukqBdTeo8dauMOn5YTsbz0z+W3pqkJ X-Received: by 2002:a17:906:6d05:: with SMTP id m5mr1935801ejr.102.1573834122769; Fri, 15 Nov 2019 08:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573834122; cv=none; d=google.com; s=arc-20160816; b=Fk5KpseYVUt6N0WyCrdEMSL7/TGSMg1RenC5OO0NYUlYbdRgC6AhPTToglSs/13xs3 TV0d1k7N+jnO65OztAj7gTacqp7dE5mGPfLmVeswf7PyHNsSnIpOAmXuDC8hhvrRiLVn DaS4j0gbN+V/R81fT/KyXcB8q6xqGEEON61uOGcw0Jdjp9LQqu6s4J/jjBYdQV0VaxVI yV7Pkom9MO4jxP/vF/6J8BF/DKz/q5MbjNgILoFGL+3jJkxKv5bfauh42SkL4BtNNysy sFMlsYGEy92/q4UZ/K1PtQEni3ORpbyQYHwIW4dhzl5x1lUj654cKWFu/RAN7g12dAzD nOEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=7RmfaCRV2HW4ZB8AueQzYdzM51SmEKPUqnP/p4psfR4=; b=M0zVCTl9pOyK85upSsj7kI5PDm2T/th5Rk+AtnV0NfhwEblescatSPf7ROvkBQx0wX hs7K5xEX3vdcW6RjWj/dGkE/NpXGho6U6ZIWhSs+fJ3nWe4vUvdxVBGFrKBrdwuQ+qUa vqgD8nkecpyHcW3f3fsWWYatoJEZVH2Fm6vrx+Swwv5wUig5xKiPYhefVm8Rx3RHH+I0 iuPyIAs0RSWWepvmWeloabf3l06OYTqLJtilVfaxY5xxNhTlOqogIuy97t+Np32AksJz RX6CAgcJgIkwa0RKHH5bDJuOhHlUdTtDQoeuZRvb1UatQHteRRQgzttrjCZGrt2rLTf/ HyhA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si6148607eji.130.2019.11.15.08.08.17; Fri, 15 Nov 2019 08:08:42 -0800 (PST) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727591AbfKOQHF (ORCPT + 99 others); Fri, 15 Nov 2019 11:07:05 -0500 Received: from mga09.intel.com ([134.134.136.24]:10613 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727423AbfKOQHF (ORCPT ); Fri, 15 Nov 2019 11:07:05 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2019 08:07:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,308,1569308400"; d="scan'208";a="214800600" Received: from um.fi.intel.com (HELO um) ([10.237.72.57]) by fmsmga001.fm.intel.com with ESMTP; 15 Nov 2019 08:06:59 -0800 From: Alexander Shishkin 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 Subject: Re: [tip: perf/urgent] perf/aux: Fix tracking of auxiliary trace buffer allocation In-Reply-To: <157165050422.29376.10692255781840811810.tip-bot2@tip-bot2> References: <20191021083354.67868-1-tmricht@linux.ibm.com> <157165050422.29376.10692255781840811810.tip-bot2@tip-bot2> Date: Fri, 15 Nov 2019 18:06:59 +0200 Message-ID: <87bltddsyk.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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