Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1316402lqt; Tue, 19 Mar 2024 22:47:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXN7KYVnWx75fT5ksgH3fy5gG/JM/kSoihw10mitZVtQZBkMhYjmCTbmvIgz4hwus/0cfNX37WnOs2Iy9FalMO/URlFeDWHVGtE/OYgyg== X-Google-Smtp-Source: AGHT+IGuh4R6HNON/AqNx+6bwEdYaZ3G1qhV5OZyEetvl118InPFCWCdHUE9h/6WfPoc0MZ+Je3+ X-Received: by 2002:a17:902:d355:b0:1de:f0af:bf41 with SMTP id l21-20020a170902d35500b001def0afbf41mr1123171plk.61.1710913675805; Tue, 19 Mar 2024 22:47:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710913675; cv=pass; d=google.com; s=arc-20160816; b=Y/wIPFrb7sZPCufQ1qguGnHqGpihPhBTrqwEwP8PV+Ngj/B/3uQ1+doeK4WQkK87y6 yzHKEtXRXZHFp3L552bUfHnPjjb8TwnXj/oXgUZ/M3dOe0ib2EiC3yuNeEkmWRdcimjH CQoyuPgHUtsjhiuQoyS8NsCVKztBT4xQSxIgp2AiaF5rilhFtEdgFF7XErEyad7IDCJC f6+PzLkVzyrYHKaTD5yZzBFGkigFQXH41EyUZzNvToPwrhP12RrmN0HAtj3wKgjRR7vf vEYdMaUx32U9kXTOb416PHDhMQVhA38pWzeh49Jh2eRT48ySsF2XxI9DjA3U0qg2uJ89 sTdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=2j9D9MOA0fmt2lZ5TlChxkcRxVAIguq0al8zOdszFZ0=; fh=CJCMsCUbWE2ZSPITV+iEeat+Mtnq13etBzTliUKhBB0=; b=U/MZufTDqIQiRD5KFsFe81r2GcMzDawmKeTuykUBUY2tsVGgefe3s9AfLwtec59V7F esOScB2WzISoTT6SLI769CcEgzj8a06ISBTEBDcPdYI8OiS3M07bu8kLIPhKF2uEmEgF kPasD/YFQceFSUYFOLDkkYCy+G3v2n5TiGwxyGCNayXleAOxr9gNFnNDoKQVnlNJffZ2 p8RkNAFPFI2mMSo5VyqtmsRBSasd3UctWPFHuLbqD86eYlyEAC7B9hv2QsXMGsDJkxNB p2hKIxGwh3nxtwna5zmCeN5jmDRa09swCSUgZ0fDXak0Im+3PRqtV2jf4M20S13b6YsC vu6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="gpARS/gz"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="gpARS/gz"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=cL1iP9cn; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-108458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j4-20020a170902758400b001dd2b63e5d5si12176004pll.439.2024.03.19.22.47.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 22:47:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="gpARS/gz"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="gpARS/gz"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=cL1iP9cn; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-108458-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108458-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 F0D49B2231A for ; Wed, 20 Mar 2024 05:47:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E29817576; Wed, 20 Mar 2024 05:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="gpARS/gz"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="cL1iP9cn"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="gpARS/gz"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="cL1iP9cn" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE3C8171A5 for ; Wed, 20 Mar 2024 05:47:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710913663; cv=none; b=sjz0SQcsdYDbryru88gk3a28FTb26pf6mX0wlFl7+tARukGyW4mbQuwrrTao8r4DK4Myr+lIO5/lUN4RMqqMFwZ1eXaVtI38fkpS489yvUsmaH3+p45fKO8aaf3M12W/cw9+uTZCn/NZD1eWQdE/oC6a3CTu+Jz2K74OjY/+T8k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710913663; c=relaxed/simple; bh=+dWcH22125yf4j/OldecbF5C+/EEbXt2IyJjBkfL2j0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mRq9Iy3TQF0VXk0FtyTNhgF95+Ek3Iy4qWb0me1BVAkEfyCvxWZtu21/tARAJsPXB1GhfKASSp3RWl8cSPLleK4X1s30ik3blIEzKHfYl+PVg1LIcPFY9knd4oXZvHTk7isGXdDTqmkaguA03I+CcagY8zXZAkojCq8WmghVBQ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=gpARS/gz; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=cL1iP9cn; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=gpARS/gz; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=cL1iP9cn; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4BA141FB40; Wed, 20 Mar 2024 05:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710913659; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2j9D9MOA0fmt2lZ5TlChxkcRxVAIguq0al8zOdszFZ0=; b=gpARS/gzcAeSnMlOu96Afx1UQGO73+RQ+NSZrMhNiCLAwXm1MP3UEKiBHfRg10C93Y+MDS +bHJ2yQbWGRVohdpAp/gckbwsyGYwyBW3Xk+AQoismidsXPpbY7GURPrcMhV0SMm4nHDI8 lQyOS/caWU+PmSP29CP6046HlC24qz0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710913659; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2j9D9MOA0fmt2lZ5TlChxkcRxVAIguq0al8zOdszFZ0=; b=cL1iP9cnjfH0KbLcuHmEVvRUghKW+qpOxwFA6a4vu952q6TU9dXXOy/Pmv5QYIDySGiXa8 Jq2+spRXDi0ZJhDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710913659; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2j9D9MOA0fmt2lZ5TlChxkcRxVAIguq0al8zOdszFZ0=; b=gpARS/gzcAeSnMlOu96Afx1UQGO73+RQ+NSZrMhNiCLAwXm1MP3UEKiBHfRg10C93Y+MDS +bHJ2yQbWGRVohdpAp/gckbwsyGYwyBW3Xk+AQoismidsXPpbY7GURPrcMhV0SMm4nHDI8 lQyOS/caWU+PmSP29CP6046HlC24qz0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710913659; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2j9D9MOA0fmt2lZ5TlChxkcRxVAIguq0al8zOdszFZ0=; b=cL1iP9cnjfH0KbLcuHmEVvRUghKW+qpOxwFA6a4vu952q6TU9dXXOy/Pmv5QYIDySGiXa8 Jq2+spRXDi0ZJhDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B386B136AE; Wed, 20 Mar 2024 05:47:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aH0ZKXp4+mVZDgAAD6G6ig (envelope-from ); Wed, 20 Mar 2024 05:47:38 +0000 Date: Wed, 20 Mar 2024 06:49:05 +0100 From: Oscar Salvador To: Tetsuo Handa Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Marco Elver , Andrey Konovalov , Alexander Potapenko , syzbot+41bbfdb8d41003d12c0f@syzkaller.appspotmail.com Subject: Re: [PATCH v2 1/2] mm,page_owner: Fix refcount imbalance Message-ID: References: <20240319183212.17156-1-osalvador@suse.de> <20240319183212.17156-2-osalvador@suse.de> <20240319162430.3e76504d06f12edc107029a4@linux-foundation.org> 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-Disposition: inline In-Reply-To: Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -1.33 X-Spamd-Result: default: False [-1.33 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-1.53)[91.90%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[41bbfdb8d41003d12c0f]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[10]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[linux-foundation.org,vger.kernel.org,kvack.org,suse.com,suse.cz,google.com,gmail.com,syzkaller.appspotmail.com]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Flag: NO On Wed, Mar 20, 2024 at 01:40:05PM +0900, Tetsuo Handa wrote: > 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(). No, it is not expected for the refcount to become 0. I do know why, but I lost a chunk in the middle of a rebase. This should have the follwing on top: diff --git a/mm/page_owner.c b/mm/page_owner.c index 2613805cb665..e477a71d6adc 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -222,8 +222,11 @@ static void dec_stack_record_count(depot_stack_handle_t handle, { struct stack_record *stack_record = __stack_depot_get_stack_record(handle); - if (stack_record) - refcount_sub_and_test(nr_base_pages, &stack_record->count); + if (!stack_record) + return; + + if (refcount_sub_and_test(nr_base_pages, &stack_record->count)) + WARN(1, "%s refcount went to 0 for %u handle\n", __func__, handle); } -- Oscar Salvador SUSE Labs