Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1298024lqt; Tue, 19 Mar 2024 21:40:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSgm1Llf/+VBnprTBvDi4srHqGzLXDGaOpDcVOaD4O+8D3c4mcnUvU9en591ciYhXlz8ms3rv2WzTf2ACkN3fsvaIboCzLFTF/SZBBtg== X-Google-Smtp-Source: AGHT+IFS/NGjN4eYGb/ffcXT/tSMW7p6leCLB1cEAuZfXKZ/vNwN0dxEZP3xOL6HfGy8ny8KhbeK X-Received: by 2002:a17:90a:c212:b0:29b:ab13:5c2b with SMTP id e18-20020a17090ac21200b0029bab135c2bmr4371124pjt.20.1710909632332; Tue, 19 Mar 2024 21:40:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710909632; cv=pass; d=google.com; s=arc-20160816; b=GjJw3Ji4ZCg2T2um+QSHEQXYHNO+LsmQMMORei6I8GPAlV+8pQTkOTNzoHRK6GviB5 sToFpynsbU13iL072stnu1nlctrexr8zveIkBvOWm5JuDqq1GxDY6CxkkFG1dnNQYGfM Fykrgk5oWe/ofBLs3bBjUZhhE8Mo1hdgvQeealIyn2cBYY5e7DeG8TYagkbu8qhLE1hN mI4KI77Kbp4XKpxpNxcnVH+opGMreKR548Qv9KquFGurhFv/JTUgKK4Ag/h8yDGZkVYv TFyfGK4Rgt3p2Spg82HRSByvCWZILjPqajE+w1a273nSs1igN1KCXvOY2MIrFMrSZXue +afw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=504dAjQqV71pEifTCt6GQ3VXYNpz+j86l6wS+xOhHzQ=; fh=/UfWn5B2CxaIS8GxrpIYtq5cNEqtBccadZDCGILNc08=; b=w9yRP1O1luS6OBkez4HdU28i4PLNe6kwln2JO2G2NvmKNOv9JWpdNrCD6MG6oyMNjq WiCFiVrF7FriZBLV0qikA6ES9DAeir530W2sb6g51Ek8y7Hsmlf2Bajg4hay9SS+2yxT nmqNVvmrJP5N4J7Kdxxg3VSetQMG4kcMetECAW/iZWetMEl0/iaJ7rZ/gAspEP336vwp Yn9HBaEpyanrNF98v09Kuu66d3W6NAjSwI1/VTLts27w8xt94lvRVjoqk05QX/osU4rU JuxaLIqC6O3OK9tk54OLohaEJr0hpFt8YbkMlh9lin/5FliqOTP7xnqy8UYUMQkgGCVK eMEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-108429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108429-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id fa14-20020a17090af0ce00b0029ffc44f5basi621152pjb.62.2024.03.19.21.40.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 21:40:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=i-love.sakura.ne.jp); spf=pass (google.com: domain of linux-kernel+bounces-108429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108429-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5E1BAB21852 for ; Wed, 20 Mar 2024 04:40:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B965014275; Wed, 20 Mar 2024 04:40:10 +0000 (UTC) Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) (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 C5A95125CE for ; Wed, 20 Mar 2024 04:40:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.181.97.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710909610; cv=none; b=JeNnnXtulCUVQJDY5LYJqeXzGyevMaKIMSH+8yCYSGV0+IPgChWH96IQpxaNl9M9BS4GIFw+nwvpdNM7smxME5m75Tytt3PPkSF6vlBLqvEG8aT1pjtFu074+TkWk95t54zUm2dmpjqROZmUWSc853pq3RvPuMWNoX15F+khK4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710909610; c=relaxed/simple; bh=7bQNjax0hyfRA1i5Jf8lHbqNrgSAIppOzgPROaQauPM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cnJ4K4fJ+3MnEKJnzxwb5CUqi7EZPlo/ckUf/zBd4ll7Q/3ey9rSBXVwCPEqJ0WM54f+jCeDZBDi0/wG//5NEFo0AZjVpSP4ejNBCsqsibUx/+bqhzUXpwNxxlhkv8aAgGdG4mOfLoD+RNW1W+lk1+D27+HZqQoR7Mp6oXJgfRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp; arc=none smtp.client-ip=202.181.97.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=I-love.SAKURA.ne.jp Received: from fsav120.sakura.ne.jp (fsav120.sakura.ne.jp [27.133.134.247]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 42K4e6fk072344; Wed, 20 Mar 2024 13:40:06 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav120.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav120.sakura.ne.jp); Wed, 20 Mar 2024 13:40:06 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav120.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 42K4e5tH072341 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Wed, 20 Mar 2024 13:40:05 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Wed, 20 Mar 2024 13:40:05 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] mm,page_owner: Fix refcount imbalance Content-Language: en-US To: Andrew Morton , Oscar Salvador Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Marco Elver , Andrey Konovalov , Alexander Potapenko , syzbot+41bbfdb8d41003d12c0f@syzkaller.appspotmail.com References: <20240319183212.17156-1-osalvador@suse.de> <20240319183212.17156-2-osalvador@suse.de> <20240319162430.3e76504d06f12edc107029a4@linux-foundation.org> From: Tetsuo Handa In-Reply-To: <20240319162430.3e76504d06f12edc107029a4@linux-foundation.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024/03/20 8:24, Andrew Morton wrote: > On Tue, 19 Mar 2024 19:32:11 +0100 Oscar Salvador wrote: >> -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 > Hmm, I guess that this is not an expected user of refcount API. If it is correct behavior that refcount becomes 0 here, you need to explain like - refcount_sub_and_test(nr_base_pages, &stack_record->count); + if (refcount_sub_and_test(nr_base_pages, &stack_record->count)) { + // Explain why nothing to do here, and explain where/how + // refcount again becomes positive value using refcount_set(). + } or replace refcount_t with atomic_t where it is legal to make refcount positive without using atomic_set().