Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1197119lqt; Tue, 19 Mar 2024 16:24:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU1PExQNN1BCck1WcKzchyr1vL7uStR/zb/fq3zPb5w0s6cezIP3ys/ofthJIt2h4NJ053SqMQUH45/DBG3meFeoGmfuENXaJvWkKgX4A== X-Google-Smtp-Source: AGHT+IFa96rdyl/NGevz1WGpnpAQQVpxH6rs9kovTtx4z5UVrYkPGJObSM2y0TxU43Vb+DoeAtkO X-Received: by 2002:a17:90a:6f65:b0:29f:96ac:9dd7 with SMTP id d92-20020a17090a6f6500b0029f96ac9dd7mr546183pjk.41.1710890677570; Tue, 19 Mar 2024 16:24:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710890677; cv=pass; d=google.com; s=arc-20160816; b=QPC9Z7nZi4lLwqRGNmJJJ3/k1XR8ZpSxvKh8CfldmSuIhf4KBHrT5NZ+hpWoIL635k qNULJFQXTOTIhjS3pOSCJ5X9wu0Jm7ZYv3CzjjNtBAy0S7+99ZEhU0VCK72HYCD49U/H 0tk/MyhhSBv0veUcltSvnFz9jWAV4VOXOINsxVRoIKlQDFgrm+qpHsXga+deSXiI0W9L wp357WX7IqiFNp1tybr9/6bUQ4Fq7lHZRpnS+XFGdOZ8qe23GxT0th+cvtmySn9rz2pT DiBxodtiH3s0vbHAHlzsWa+bEsTEAnkNAtRtsXzZY+sXqpNHLC8yk/EuLhYNd7cDignb eHJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=92S4tfax916iNYmisw89+bixhhyHew1EHLjOb6NFPUo=; fh=sc0+lf0kmGGt+gJiaxU2kEq2LStj/N8MlQeMDbPt4aE=; b=oYzSmIP5kyQ37SCFiR0VxYNJCCP5GT/3VykTmVoDWhaa+beSsHvv+cfYw1hFMUp3Ik 0lszNuhQHAgb3GU67FrUZ1m09Wwn/YdApZtGmbrSGsDD66uae81iMB3vcrlcMVQWaEf3 UA9rxiDzqvtESD+8k1Dp8rDO9+zJ6kXtcTN37EhsQYSsrhfL+msX3lZbq6Wh8wKamNJy xne+7DRCSCzdYos8wHgIQJNyLeDZXXBlsoJjs6EoNFJFw1PCPMhtRUBieEfvnGyDpGJp Fry5choW8bnXCt6gWhzacvxUXOiRfwNEodvdZuVuhNas/Y5oJPYt5Ae9zdsbGHKoMrXR g7fA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="fVe21I7/"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-108232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108232-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id nl11-20020a17090b384b00b0029dba46822esi198397pjb.184.2024.03.19.16.24.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 16:24:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="fVe21I7/"; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-108232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108232-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 41D622840F9 for ; Tue, 19 Mar 2024 23:24:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFFD15FDA9; Tue, 19 Mar 2024 23:24:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="fVe21I7/" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3D395FDA1 for ; Tue, 19 Mar 2024 23:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710890672; cv=none; b=s6IUhzPBqdavJJk5YQlt2K4qt7qnTJNEp/x9cb2DfpI2JDqxj7nDZrJYVGO/3Rr6VlVFIAdzE+dkL8aCwFfYaFEdAzcxNjsssN+hLB10Rvn8s0deiUFGFVOXPIr4/zwV4bTNCmYJ6gmofb565dzdmmmhHzjaqhoYSww5E1qUzEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710890672; c=relaxed/simple; bh=W0aPdR/diOGHsmOKFCEcwEf5899ewqDXOmarYwURMdE=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=FDphNEbBDhhMG7VogoYU/+855uKyNHpbFK2I5MOh9cirOwqFB+KH7zqhHEBbjVmUPEIufjBaW8ZV8wQiqQwyCLbglsEoz7YKheh4BM7HIV2lMJDyjGIbkJYYxC/rnHK/yYKgRq36JX6y8QYaj++3pjaCPcjLgDqHE1EuSz4F0P8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=fVe21I7/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DFA5C433F1; Tue, 19 Mar 2024 23:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1710890671; bh=W0aPdR/diOGHsmOKFCEcwEf5899ewqDXOmarYwURMdE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fVe21I7/rxcH7jmAQgQcOZN9JifKbY3RhgUPXm/lz/KA/zjy+uEAh3fju4mUOrgcS y4jA5pJT/g1cyjQMBVE81tcMGRsihZGT63XwsSYaAI7CTgrDm2Jxjh+zDDH1vOcOQm IP4d9VWN63ZvSxUUaiEtOxla4t+XzDi6Q46MsiI4= Date: Tue, 19 Mar 2024 16:24:30 -0700 From: Andrew Morton To: Oscar Salvador Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Marco Elver , Andrey Konovalov , Alexander Potapenko , Tetsuo Handa , syzbot+41bbfdb8d41003d12c0f@syzkaller.appspotmail.com Subject: Re: [PATCH v2 1/2] mm,page_owner: Fix refcount imbalance Message-Id: <20240319162430.3e76504d06f12edc107029a4@linux-foundation.org> In-Reply-To: <20240319183212.17156-2-osalvador@suse.de> References: <20240319183212.17156-1-osalvador@suse.de> <20240319183212.17156-2-osalvador@suse.de> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 19 Mar 2024 19:32:11 +0100 Oscar Salvador wrote: > Current code does not contemplate scenarios were an allocation and > free operation on the same pages do not handle it in the same amount > at once. > To give an example, page_alloc_exact(), where we will allocate a page > of enough order to stafisfy the size request, but we will free the > remainings right away. > > In the above example, we will increment the stack_record refcount > only once, but we will decrease it the same number of times as number > of unused pages we have to free. > This will lead to a warning because of refcount imbalance. > > Fix this by recording the number of base pages in the refcount field. > > ... > > -static void dec_stack_record_count(depot_stack_handle_t handle) > +static void dec_stack_record_count(depot_stack_handle_t handle, > + int nr_base_pages) > { > struct stack_record *stack_record = __stack_depot_get_stack_record(handle); > > if (stack_record) > - refcount_dec(&stack_record->count); > + refcount_sub_and_test(nr_base_pages, &stack_record->count); > } mm/page_owner.c: In function 'dec_stack_record_count': mm/page_owner.c:226:17: error: ignoring return value of 'refcount_sub_and_test' declared with attribute 'warn_unused_result' [-Werror=unused-result] 226 | refcount_sub_and_test(nr_base_pages, &stack_record->count); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors