From patchwork Wed Dec 11 04:32:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13902925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A055AE77180 for ; Wed, 11 Dec 2024 04:33:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 212766B0248; Tue, 10 Dec 2024 23:33:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C01A6B0290; Tue, 10 Dec 2024 23:33:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 060EB6B0291; Tue, 10 Dec 2024 23:33:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7D1736B0248 for ; Tue, 10 Dec 2024 23:32:59 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ED62680E46 for ; Wed, 11 Dec 2024 04:32:58 +0000 (UTC) X-FDA: 82881406986.08.3FC1287 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 03F6418000E for ; Wed, 11 Dec 2024 04:32:39 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EDZWvep3; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733891566; a=rsa-sha256; cv=none; b=cQzzspfpYR80Pfsq+sD8v7qTb55WledpU9I/ZmPXYI5Wpa/XckXvnrUh9o2nrqC7G/hs5n rN/UtYwZEgJ0DhKFH10le0Mb0K7Q1zWZcuU8AlC5Fv+zv5o0m7/ZMkSj2h7W+B/WByr1N9 d+upII64LtboKP1U2wxXKr3Jiq5u3a4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EDZWvep3; dmarc=none; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733891566; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=lJ3CGzKytUYmJ3F2enw41nIOea2qq4EU4o9MW/pKz3I=; b=M10rwq1sfgJXzm3lZH6+TWjcVKP7lcavqibhZqFuzdU2sr3KQnv/XqEK0G79QtoAoscfSI fT6jNm/78lunw9kqHrbevFTxbycroP1M5hBMlCKmcptWtueiXTgWKFc12byjCre1LKjMgC SymREkDTvmA2KeCBwSv/3EF+kDtyEYg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=lJ3CGzKytUYmJ3F2enw41nIOea2qq4EU4o9MW/pKz3I=; b=EDZWvep3NFgLMs6GvSouLTYmC6 W1UxA0/qNxUbipKzXswAFHMdDk/fzN/UiG14Er/MgKU1bghr6WJPHVljX67WaTQ+TtRN0G/xSRbBn KjNn7zKPSKgnOutqBT4awHa89PW25cw5TXeJPDJQrfYzR7NiG/6UIexAPrqxvGNUOqeG96TbHvLEK rDYlUo5x6L8EDleYYrNSPBjzlV74s1NhF+hh1aQN3TQL2ckwPbNIT6NFIZmY4+K3rcrky2Iz/Ijle MjVYgRc2aASpL9ETyOCHTdZ4kTtr5DZx/T/5mxSQvaqaMEGkLeZrUIzsDij0qavK9JtZl1h4isiS8 d79Mt7ZQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tLEP7-0000000DpR4-17Cr; Wed, 11 Dec 2024 04:32:53 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Christoph Hellwig , linux-mm@kvack.org, Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , cgroups@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/2] vmalloc: Fix accounting of VmallocUsed with i915 Date: Wed, 11 Dec 2024 04:32:49 +0000 Message-ID: <20241211043252.3295947-1-willy@infradead.org> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 03F6418000E X-Stat-Signature: rgcmwopaoasrrtotcp6huthwaknmmqft X-HE-Tag: 1733891559-12052 X-HE-Meta: U2FsdGVkX1/YxktrPsg4wfYIGJnjsfduRyl+qSvPGKeB1L8kEBncuetMYMTgm+Oxu2eKvDBqp4IFlALrmS/ZJG+y9Uvtt9jpLv5Kmas8dublBwqJyrGwAHI4uItU/0c0uk3emp4MnOgoIW0Hq8LJ13n8DTD3Pla58t4xFXwD7h4rUsTotE3AjZHxtDkH8hp6Dlzkd3mLafRKXrHajZWkRCC1uQcYJVdyTUGszW6e3DCZxYkK8BnxdeumsUgRLuB1nJizg+tJad4jnKIbPpZypWx3rsGtKUPQ17+EVUOKMXQLFv8n0yPV1njsG9uws1N8ilVIroeJKqvFabLYApdWDmWayKYxfVb2bElxv4q40PSIwRwNjliFFZDSAKySyl8HR5bT4svU6sbPMkRv2/GOxk9v7j/veof5iiENCNGgFpYgxf/+1B6FMg901ET03Z0blJ0QYycqoLoW0t2gzbC4LLwhRstAyzeLQTkkXbxU82a+n1KMBzhyDmxjVEqbEB3lzXy3pr+7GtWritXrKnrkWXt+vvvUm6QtPm30+KARqHBzvUxGTGt8l7xrLHL/fMuCrc05Tx1D/O/oZ5xCH5wqWVuSpqmY7evUfHNvvnfZWOihmXTPj+BIIWrW3Svex19kgpCwqm6HFgMUceKjETRQbf3KKSYSgQ+JTa7PZfqNd+0ejRPaeismDvyEP83OuOaNIimh4X7hxLfGkqfiKEWlcXAVDEEaFhdxeevavSgKPkWa4AokIqZZ1mTSVzH7WE4wlnbOw7tC1NImVE811vPLnSEE92FePIuRjJodbqKnrfQsTFvqzcT6j+6envMVI9kxWTCiQ0QGkaVbax4ertydJE3+bYEJ7QgdQtAuGRxAmq6GQA6wf+jReM1oRT/wmMGndv2nDZ3cU72brtz0aE6//5oawyoPdrW4swnbnItmEfZznwENot0cEia6oI3xaHGy/4BTsnhH3vltIWm2wjF FKI6bAU/ QiCeSpB5hBF4h0KDC+muAkKnGmGyzjzklIpxqdK/dA2lw5MtFmLztHdkFe4Zyk9gpiBtY/jx5Cc0fh7Wg21ze8/ofglwcb4ufwPeXJOYioMR4E1lZ/YzmeQmaf8wXat2yAxynJHYnAluH3Fb5jXx4hm8lGmXIZFlGytFOv6iA9J8J1tRltdFZyeAhaN5XR3+WxFfm4FbMaI1L28ldScgQIFD9jKlgulyQlJ/OYY1IHjsM51tc1zTSfatljWvdY9JqCuYsSH55LXz/+Zo= 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: List-Subscribe: List-Unsubscribe: If the caller of vmap() specifies VM_MAP_PUT_PAGES (currently only the i915 driver), we will decrement nr_vmalloc_pages in vfree() without ever incrementing it. Check the flag before decrementing the counter. Fixes: b944afc9d64d (mm: add a VM_MAP_PUT_PAGES flag for vmap) Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt --- mm/vmalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index f009b21705c1..bc9c91f3b373 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3382,7 +3382,8 @@ void vfree(const void *addr) __free_page(page); cond_resched(); } - atomic_long_sub(vm->nr_pages, &nr_vmalloc_pages); + if (!(vm->flags & VM_MAP_PUT_PAGES)) + atomic_long_sub(vm->nr_pages, &nr_vmalloc_pages); kvfree(vm->pages); kfree(vm); }