Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2418968rbb; Wed, 28 Feb 2024 00:47:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUKmQUCNCgpWid4booGAK7ClbMKMyq6/LRLsxXpR3JsXv8c5NApZJJ5KUXzZeplRg3uJECrKeLgn6a9GHepCRPUDFqVDQedHQ+pILmUEQ== X-Google-Smtp-Source: AGHT+IGtzzOYSoE4Q1bAGYWfx3FiA00v4MuOzRLvUANTY2qnR4E5JMQI3m85L6sUPtCb0wDoEEVp X-Received: by 2002:aa7:d30e:0:b0:565:bd4d:8a89 with SMTP id p14-20020aa7d30e000000b00565bd4d8a89mr7381183edq.31.1709110057288; Wed, 28 Feb 2024 00:47:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709110057; cv=pass; d=google.com; s=arc-20160816; b=UFGc0wVu6f2mkN8r4aRJB5t3coInJEc4W6amzCXYp2ahu+TDkWKqAKPcJ2s8c1/yZI 3NTlKS7nj0kS3W9sFk1oeoMU7ELF2LZdXcXavndYfrpB4BPbxpuS8BHmFtrTgnRG9Ylc L5MsOASh4DGAlqCyMyA+qPVn+R2KpJES0ev0e2x1h9omuPAk1G8i0TCmn+NL5z5rCF5s 5W2tk+7JcTkaeZl28WBzfbtQcFS2CCANcvyO3LKlIRz+7FLoW8QxNFrcXJosS+1vlKwf 26JM4TUspq9uUHhfaBS42iW42Qz1evKV27z/CReoVV729BEgaConSLb2qs3K5xxNDQeY e61Q== 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:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=Vj8SBiVnmCzYeLcoo696dWgrqk2e7VmSkmzYdiIhZIA=; fh=dOHsy3mSRCJvTZwWeFaoCuCHq/O8VVJOOHQkFc4Oa7s=; b=wWFUbBfCjVBt/obHUnGT6YowLM1wGQSIOm2AJvtc3aSUkxl+876HHN+Bt6zwTzhinv IOQEF0Edp9l3+uDiQUqwGx/GXOLHHekj54GraC9w+jFq0Bm1Yh4A1iEkLgv1w8g0rSx2 1mgWLvOIFb3ON9Sos5MFL/jSIPHiNzHdL4FO22e73OhwtIuhGfvErV862pVIZq97UDsy 1STsbutiaLvV7IPjq0Q4xPYcZq2HMwENG8rjTjlZq9WK03i+aIPQAobYD0rsJJFWHHhN y843021AB0NbsJCTYIZGuGMpvwc/jUe3CukEOAhtpWojZaJWzRSKUslwIW2UqoRyX19g bciA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=s6ogdVMW; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=s6ogdVMW; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-84698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84698-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n2-20020aa7db42000000b005610b043f9esi1442486edt.384.2024.02.28.00.47.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 00:47:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=s6ogdVMW; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=s6ogdVMW; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-84698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84698-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 am.mirrors.kernel.org (Postfix) with ESMTPS id DB4AF1F2156C for ; Wed, 28 Feb 2024 08:47:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1E192DF87; Wed, 28 Feb 2024 08:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="s6ogdVMW"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="A7eYUasH"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="s6ogdVMW"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="A7eYUasH" 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 D07E21DDD1; Wed, 28 Feb 2024 08:47:19 +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=1709110041; cv=none; b=FnUZpD5nTKiG9gucLqLpYaE1pbc8eoT+UOar7ntveeV8EcHGwoelPREAg+d878/NqKMFJ2lTSuk6evrAIOw4SL1rWMuIkEKAQ+0LagK4J6ViMfaGQMvrcHwB4f2qgWM57AeLYT/kqSo6gWpTOMnJMgep3Uk6mGoOs6P3wuGoveU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110041; c=relaxed/simple; bh=da7fKvfglkLdtpNErLBCbJjKSB2vf0y1Y/4zsoOTLBk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=C6wk/hLLLFXv9+S5ZZiY112tzk6ztmeF75KAyQHzipytoFmz2qVmPPpBMhn/NkL2fmRYyzFOt9JM8HDgOaiOsB4hXBTYoJfE9jygWUfvX9iF1Q/XRYYLsn0gvJIT2jzwGVLKH6HzCTo/jhaL1avPqaf3uFc3x2aQHq5AWTmL52Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=s6ogdVMW; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=A7eYUasH; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=s6ogdVMW; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=A7eYUasH; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz 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 0A4421F7A4; Wed, 28 Feb 2024 08:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1709110038; 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=Vj8SBiVnmCzYeLcoo696dWgrqk2e7VmSkmzYdiIhZIA=; b=s6ogdVMWJ9Yj9M6VNL5ljL6Ihfa+xkxsw6TeA+cvHUv191l4MKLQpNULNHkeB8GJ+Auu9v PlYnqE2eAGQFWv8MbBbeDgIXLU4P3Vp4vlAlYxXdU17cH7RDGQc5/8z8it3Ueoh+CGKfRr MPuPGNG5Utti2cOzW55ELkB4rw0zp6Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1709110038; 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=Vj8SBiVnmCzYeLcoo696dWgrqk2e7VmSkmzYdiIhZIA=; b=A7eYUasHGOqwTH88ZwnQWwVHo65JIkxjb91z9NcIz/jEEyMjS4CeV6OF9o9IbMR0a8tvDr fG/C/fs7C5VAitBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1709110038; 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=Vj8SBiVnmCzYeLcoo696dWgrqk2e7VmSkmzYdiIhZIA=; b=s6ogdVMWJ9Yj9M6VNL5ljL6Ihfa+xkxsw6TeA+cvHUv191l4MKLQpNULNHkeB8GJ+Auu9v PlYnqE2eAGQFWv8MbBbeDgIXLU4P3Vp4vlAlYxXdU17cH7RDGQc5/8z8it3Ueoh+CGKfRr MPuPGNG5Utti2cOzW55ELkB4rw0zp6Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1709110038; 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=Vj8SBiVnmCzYeLcoo696dWgrqk2e7VmSkmzYdiIhZIA=; b=A7eYUasHGOqwTH88ZwnQWwVHo65JIkxjb91z9NcIz/jEEyMjS4CeV6OF9o9IbMR0a8tvDr fG/C/fs7C5VAitBQ== 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 6D9ED13AB0; Wed, 28 Feb 2024 08:47:17 +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 d+w3GhXz3mXBIQAAD6G6ig (envelope-from ); Wed, 28 Feb 2024 08:47:17 +0000 Message-ID: <6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.cz> Date: Wed, 28 Feb 2024 09:47:17 +0100 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 v4 19/36] mm: create new codetag references during page splitting Content-Language: en-US To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, mhocko@suse.com, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, penguin-kernel@i-love.sakura.ne.jp, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, vvvvvv@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org References: <20240221194052.927623-1-surenb@google.com> <20240221194052.927623-20-surenb@google.com> <2daf5f5a-401a-4ef7-8193-6dca4c064ea0@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -2.79 X-Spamd-Result: default: False [-2.79 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; BAYES_HAM(-3.00)[100.00%]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_GT_50(0.00)[74]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[linux-foundation.org,linux.dev,suse.com,cmpxchg.org,suse.de,stgolabs.net,infradead.org,oracle.com,i-love.sakura.ne.jp,lwn.net,manifault.com,redhat.com,arm.com,kernel.org,arndb.de,linutronix.de,linux.intel.com,kernel.dk,soleen.com,google.com,gmail.com,chromium.org,linuxfoundation.org,linaro.org,goodmis.org,linux.com,lge.com,bytedance.com,akamai.com,android.com,vger.kernel.org,lists.linux.dev,kvack.org,googlegroups.com]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Flag: NO On 2/27/24 17:38, Suren Baghdasaryan wrote: > On Tue, Feb 27, 2024 at 2:10 AM Vlastimil Babka wrote: >> >> On 2/21/24 20:40, Suren Baghdasaryan wrote: >> > When a high-order page is split into smaller ones, each newly split >> > page should get its codetag. The original codetag is reused for these >> > pages but it's recorded as 0-byte allocation because original codetag >> > already accounts for the original high-order allocated page. >> >> This was v3 but then you refactored (for the better) so the commit log >> could reflect it? > > Yes, technically mechnism didn't change but I should word it better. > Smth like this: > > When a high-order page is split into smaller ones, each newly split > page should get its codetag. After the split each split page will be > referencing the original codetag. The codetag's "bytes" counter > remains the same because the amount of allocated memory has not > changed, however the "calls" counter gets increased to keep the > counter correct when these individual pages get freed. Great, thanks. The concern with __free_pages() is not really related to splitting, so for this patch: Reviewed-by: Vlastimil Babka > >> >> > Signed-off-by: Suren Baghdasaryan >> >> I was going to R-b, but now I recalled the trickiness of >> __free_pages() for non-compound pages if it loses the race to a >> speculative reference. Will the codetag handling work fine there? > > I think so. Each non-compoud page has its individual reference to its > codetag and will decrement it whenever the page is freed. IIUC the > logic in __free_pages(), when it loses race to a speculative > reference it will free all pages except for the first one and the The "tail" pages of this non-compound high-order page will AFAICS not have code tags assigned, so alloc_tag_sub() will be a no-op (or a warning with _DEBUG). > first one will be freed when the last put_page() happens. If prior to > this all these pages were split from one page then all of them will > have their own reference which points to the same codetag. Yeah I'm assuming there's no split before the freeing. This patch about splitting just reminded me of that tricky freeing scenario. So IIUC the "else if (!head)" path of __free_pages() will do nothing about the "tail" pages wrt code tags as there are no code tags. Then whoever took the speculative "head" page reference will put_page() and free it, which will end up in alloc_tag_sub(). This will decrement calls properly, but bytes will become imbalanced, because that put_page() will pass order-0 worth of bytes - the original order is lost. Now this might be rare enough that it's not worth fixing if that would be too complicated, just FYI. > Every time > one of these pages are freed that codetag's "bytes" and "calls" > counters will be decremented. I think accounting will work correctly > irrespective of where these pages are freed, in __free_pages() or by > put_page(). >