Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp8280ybs; Tue, 26 May 2020 02:14:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhSEiihe41OKB9Rp5gfb4myU7vdvFBINTWR+u2yNBN8m4Jg0hMXDkzVp/UZac+MwAY4HlN X-Received: by 2002:a50:cd57:: with SMTP id d23mr19248959edj.181.1590484447430; Tue, 26 May 2020 02:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590484447; cv=none; d=google.com; s=arc-20160816; b=OG9oDbfzBF0c4LO0IawewPdrpQcOWTGudBGgJ+FsJG3GlsA8B2+7962ewqcRLwd7je BacZPNy36N4au4EhK9Gpk6GCkLcIAAxD5zRghiyqns0LM85PNH3tn2WWwnrNF/Pg5x7z Jf4KDnyvVOF4EIp6aDreS/yoOxSP0NYl3KRUPuuw+zk41TKcFF2BS60kO/pvQ2w2FJbv iee/zI3MP+muSavGwMdHL0N7CDAb4x9jLwpHSwH1OXMSIIHd8Lx0NbH/k6kbX+KYIJuv oSCpqR5zEMqi9Lt88baUuzjyD0vgjXs5osmfOpjrhXO9DIJGhTS4UwtUnCevY9nkT+aG Ek4A== 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; bh=VXFJrVIzENMgiKmMadsa91fu2hezqv70d32xRxuO6Qk=; b=vUqCkK5hP8V79vDE9So+jt5VCc2ON6hbcwU31VgTI/4GiVO+sNrXdO3c/UNoC4wjNG EDRO0JE36pwzxAn8mRuWyda21Tji8Er3xWyuo24R80QB2QMZnSVqZniIBZzZHhgDMEC/ rBPR8TVIttV9uJvYt6PgjonZ/nk2uIYRSd7+kkcJPJt+zK6fAINkb5uKzwc8IIflHxBv CeMaLKuOyN1U00FQJwgDXTQzyKWu7QK3EdKSzIKL5sRWfShHSpbQad6OlCgUMmG7wX1o AlrxwY4mski/q9epQ2P3NqhoKHTYjP9sLFLrSsx6Bene0fdBjMawq/jwJmCaHNouzIqq 9cwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds2si12860329ejc.114.2020.05.26.02.13.44; Tue, 26 May 2020 02:14:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731748AbgEZJLM (ORCPT + 99 others); Tue, 26 May 2020 05:11:12 -0400 Received: from foss.arm.com ([217.140.110.172]:47932 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731491AbgEZJLL (ORCPT ); Tue, 26 May 2020 05:11:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8251B1FB; Tue, 26 May 2020 02:11:10 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C1AA3F52E; Tue, 26 May 2020 02:11:09 -0700 (PDT) Date: Tue, 26 May 2020 10:11:07 +0100 From: Catalin Marinas To: Qian Cai Cc: akpm@linux-foundation.org, vitaly.wool@konsulko.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/z3fold: silence kmemleak false positives of slots Message-ID: <20200526091106.GA17051@gaia> References: <20200522220052.2225-1-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200522220052.2225-1-cai@lca.pw> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 22, 2020 at 06:00:52PM -0400, Qian Cai wrote: > diff --git a/mm/z3fold.c b/mm/z3fold.c > index 8c3bb5e508b8..460b0feced26 100644 > --- a/mm/z3fold.c > +++ b/mm/z3fold.c > @@ -43,6 +43,7 @@ > #include > #include > #include > +#include > > /* > * NCHUNKS_ORDER determines the internal allocation granularity, effectively > @@ -215,6 +216,8 @@ static inline struct z3fold_buddy_slots *alloc_slots(struct z3fold_pool *pool, > (gfp & ~(__GFP_HIGHMEM | __GFP_MOVABLE))); > > if (slots) { > + /* It will be freed separately in free_handle(). */ > + kmemleak_not_leak(slots); > memset(slots->slot, 0, sizeof(slots->slot)); > slots->pool = (unsigned long)pool; > rwlock_init(&slots->lock); Acked-by: Catalin Marinas An alternative would have been a kmemleak_alloc(zhdr, sizeof(*zhdr), 1) in init_z3fold_page() and a corresponding kmemleak_free() in free_z3fold_page() (if !headless) since kmemleak doesn't track page allocations. The advantage is that it would track the slots in case there is a leak. But if the code is clear enough that the slots are freed, just keep the kmemleak_not_leak() annotation. -- Catalin