From mboxrd@z Thu Jan 1 00:00:00 1970 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 3F4BBC54E4A for ; Fri, 8 Mar 2024 07:53:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDA406B0342; Fri, 8 Mar 2024 02:53:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C8A356B0343; Fri, 8 Mar 2024 02:53:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2B2A6B0344; Fri, 8 Mar 2024 02:53:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A42F76B0342 for ; Fri, 8 Mar 2024 02:53:12 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7DD9312147C for ; Fri, 8 Mar 2024 07:53:12 +0000 (UTC) X-FDA: 81873106224.25.E2326C1 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf10.hostedemail.com (Postfix) with ESMTP id 33DFDC0007 for ; Fri, 8 Mar 2024 07:53:08 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=oBA29ilh; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/ssvpF3u"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=oBA29ilh; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/ssvpF3u"; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709884389; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TEzBdz5tlejxHIWRu4GFOXa0dCDGc6JHxZ8PAzaMiFQ=; b=mMtyTVfuZQmQ1UhHED1SFOa3t4i5yDT/yV+PQCcZh3r7iVl4efkQYsiH66ED+F4rCdSdnp YWfMdvxH8S5KdyL4PjuhetVy3GyW+RTyLV84tudfDGd9zGJ8aYp9xSHeWA6OdFIVrbz2I4 yHD+Yb4L1AqcI/BAgmMawEoxHT30FOA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709884389; a=rsa-sha256; cv=none; b=MZmDc3Y8V6htmmOT76X5xK39olEQh4ifWknPQ+qSZ8j9n3BxwM0kpWhT5EEi2VnOf43Ffz aZJ/ppFim2n6Jy31VEtjMMQiTT3/2pr5WrBCX2qQII8l46+CM6KWZeMOoWlmAOXuFB/kd+ CDx2yDHnxY57M4iJwP+s6qWs91qXMOw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=oBA29ilh; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/ssvpF3u"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=oBA29ilh; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="/ssvpF3u"; spf=pass (imf10.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 112375D273; Fri, 8 Mar 2024 07:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1709884386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TEzBdz5tlejxHIWRu4GFOXa0dCDGc6JHxZ8PAzaMiFQ=; b=oBA29ilhTB7HfBl6EYJt+liQQqFP+LB3mSqcHguimEdxgW3ZJwT0XacI2JN5Mmat8NizN6 OA8fBO3z5wG97ahOECA0/z9qHD6uPOUpRlzi1DFUMuK71H08HQ5vsW4FXDw9wYSxHxAm4o ch7+X6c1kVLAihKpPjqzhBM2BzIqNdk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1709884386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TEzBdz5tlejxHIWRu4GFOXa0dCDGc6JHxZ8PAzaMiFQ=; b=/ssvpF3uoes9ULrACOYM6H9o6VQH2ASD9Rwx0o4dvAd5CfpSpehnwpSBPvItk5XSo/zQJi TOShrmYSIh5jHACg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1709884386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TEzBdz5tlejxHIWRu4GFOXa0dCDGc6JHxZ8PAzaMiFQ=; b=oBA29ilhTB7HfBl6EYJt+liQQqFP+LB3mSqcHguimEdxgW3ZJwT0XacI2JN5Mmat8NizN6 OA8fBO3z5wG97ahOECA0/z9qHD6uPOUpRlzi1DFUMuK71H08HQ5vsW4FXDw9wYSxHxAm4o ch7+X6c1kVLAihKpPjqzhBM2BzIqNdk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1709884386; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TEzBdz5tlejxHIWRu4GFOXa0dCDGc6JHxZ8PAzaMiFQ=; b=/ssvpF3uoes9ULrACOYM6H9o6VQH2ASD9Rwx0o4dvAd5CfpSpehnwpSBPvItk5XSo/zQJi TOShrmYSIh5jHACg== 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 ED3EB13310; Fri, 8 Mar 2024 07:53:05 +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 Th58OeHD6mUNSAAAD6G6ig (envelope-from ); Fri, 08 Mar 2024 07:53:05 +0000 Message-ID: Date: Fri, 8 Mar 2024 08:53:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Vlastimil Babka Subject: Re: [PATCH 1/2] mm,page_owner: Check for null stack_record before bumping its refcount To: Oscar Salvador , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Marco Elver , Andrey Konovalov , Alexander Potapenko , kernel test robot References: <20240306123217.29774-1-osalvador@suse.de> <20240306123217.29774-2-osalvador@suse.de> Content-Language: en-US In-Reply-To: <20240306123217.29774-2-osalvador@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 33DFDC0007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: yqxfhfzppmu1jgysdo3sowdk68pk9bci X-HE-Tag: 1709884388-438194 X-HE-Meta: U2FsdGVkX19UhItthC7G5RxzvpzlV3MCSirA6gaXM7B5PjP69wfZmmaVlTRHGy63hdl6HiJVLM7neYT6DTLDryKCFEF4YDsBk1O/5EV0X8sZPSI9MekuEhO9YQ0YrsY8vA2YX0q9lEzjFN4MXWF7s2zSG43Rwowp3PYBeFN9earSQAKjDlAGTH4s8pZr1FiXUWUcWYxrVaeGI8Vs3zMRbawXhfJFLqoRKHwa2c0EoRFN7NqCQg/4VXRNvRDSbgP7wrfsjA6HWeeubK3YxQ/jCKKYNNEDyRVJ9IU6vsntoS/6VUdboJOxW3JjGrh2sf4sveVfDzumPFksarhR9hGvYYXztz3zs0N3ND1/IwYF/PFVuQkW6B3CLsC7BpnKj4/AguV055gXlW9m9sptxwY+3Fq6644RLEET0XaHExuUEujO8PnSs07rC4mK2xza+bUw0doCZpQHdUIcDUGeCDGcu0a+Pl1LgsC9E96/zWCidumiznIfxNtJ/jsw+E8e42BmKmB+UYGwJBU9dnl6l1xaLb3aNJauTmE3DE34h1v3ey72shsKlRIFo+XlhXvFfZopnB2vemZVA4IBrBeJinH2Gb0fRvI8wqv3pZqAZX7PzoAO4ps3Y8HJFHa4J659mYcYp7lQGEnFVTJqU4y3oLmxWrYQoHJaUgoXf1RmL2mrrSyXRoFC48ZS53W7SMattOolvpD9OlFS6QkkeoBMV9qnCiN24wQKT8+xfrQywcbP4bv+KkRZDAqoiDu6UPC0fGfvx0N7dW+y74dZuChI5WM2ZFKtCnqVXcPAo7mywmg0bFickOvplbBE8QHi7BE3o52xI4VVSo40thHXkevQh2JHjCS6MvVwsJKXmBfgDCoz5sXAMfZ/7dc5agzWINZXmSiM6fkD0NYsAvsE7JTMPBOsXkswVxii8iqSEFhw7vzO9IIe99k8zv6NxQOcDqlJ00t125ClsQLF4TWGE1joXP7 15pZZof0 mjZ35+wfMtOvcF6M= 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: On 3/6/24 13:32, Oscar Salvador wrote: > Although the retrieval of the stack_records for {dummy,failure}_handle > happen when page_owner gets initialized, there seems to be some situations > where stackdepot space has been already depleted by then, so we get > 0-handles which make stack_records being NULL for those cases. > > Be careful to 1) only bump stack_records refcount and 2) only access > stack_record fields if we actually have a non-null stack_record between > hands. > > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-lkp/202403051032.e2f865a-lkp@intel.com > Fixes: 4bedfb314bdd ("mm,page_owner: implement the tracking of the stacks count") > Signed-off-by: Oscar Salvador Reviewed-by: Vlastimil Babka > --- > mm/page_owner.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/mm/page_owner.c b/mm/page_owner.c > index 033e349f6479..7163a1c44ccf 100644 > --- a/mm/page_owner.c > +++ b/mm/page_owner.c > @@ -107,8 +107,10 @@ static __init void init_page_owner(void) > /* Initialize dummy and failure stacks and link them to stack_list */ > dummy_stack.stack_record = __stack_depot_get_stack_record(dummy_handle); > failure_stack.stack_record = __stack_depot_get_stack_record(failure_handle); > - refcount_set(&dummy_stack.stack_record->count, 1); > - refcount_set(&failure_stack.stack_record->count, 1); > + if (dummy_stack.stack_record) > + refcount_set(&dummy_stack.stack_record->count, 1); > + if (failure_stack.stack_record) > + refcount_set(&failure_stack.stack_record->count, 1); > dummy_stack.next = &failure_stack; > stack_list = &dummy_stack; > } > @@ -856,6 +858,9 @@ static int stack_print(struct seq_file *m, void *v) > unsigned long nr_entries; > struct stack_record *stack_record = stack->stack_record; > > + if (!stack->stack_record) > + return 0; > + > nr_entries = stack_record->size; > entries = stack_record->entries; > stack_count = refcount_read(&stack_record->count) - 1;