Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp442357rdb; Sat, 17 Feb 2024 16:44:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXhtSZ3vRx59zOfGjVl9O1PBmaDdopx48jNLVgJAAkeWajDlu3cTiFZ6vW6ct610JzBDoEPiyBxyYFg4/ngqGpgk4sgLUzSpV5DKqmOeg== X-Google-Smtp-Source: AGHT+IEXYaxjaTsPsqXBYb0FzeQov+ZKPvN4YtR9W6zu8QzkxJhxggj/Zlq7Onl50DkkSRd1zP10 X-Received: by 2002:a17:906:411a:b0:a3e:5cba:e005 with SMTP id j26-20020a170906411a00b00a3e5cbae005mr462641ejk.64.1708217073809; Sat, 17 Feb 2024 16:44:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708217073; cv=pass; d=google.com; s=arc-20160816; b=JKpgEpjYQn+Bd6Jg9rgPc4SatQqLeAwBOv+eYuO6592nBKa95154HQx+YiNhDlPqMt hTh/bZc6FTCJVJn72nRecSwffS/KVx/ItAsZ19GH28tJp6gT12rqmsy9+qnfP1TeeC0H dWx1k3Gyws2BHs5wOR/gQouA55TUEIInqfpR8TR15dFSTibs7ns7n8FsxdCAdH0zoAv7 SZy+dYtR90Yl662RklZF75L/RMghdTRYy9zC3UE4z1UIAA40XxaMYMtP4cMNz7TEL9F/ a83hlakoBExyIy0QY7Yjir+cW6zC9VUQHlFI5xXjnXIG2yC6mrzkq6TZHLH3ObJP7bOh JI+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=cFEGcM8EospHG4JmqyUXYLdSoH1Alzf1U0lPv6eqJTM=; fh=2TVdeiF/hVRgE5k4ZhevNhhZTKccpdb1aLclij2UCt8=; b=kZJG060yefSIq1EEsAkQrZy5dWpavse3zeYCyDHAmLJRhu3rbwj0skpBWLAicYeEIb SLS5MyKifHbs0Z8aXBydYr/aOwkMvZ04/4dwWSYNrQ4/IfdaszEpUqpkUHGbaQqRp28+ L4f96ou0940oAzg7BrWTKhYvJQS25Py2Uwz9/BXOB4IkT5/w//hzO+bvGJzY2rG1/urD Nb81sMPW0PjZP38t1tBD4mGLCjE4Z8YD5CY2rOqPpGtj4kMfI423O5CWyXqT886pLkG/ AxoBUCXZ0phTGiG1dqhZhjj1b6BOFIEkDfMLnmYupvdGOAj9W5Qpn5ZWViz9JWhP+xsX wlXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="T/xwhoLJ"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-70125-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70125-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gh4-20020a170906e08400b00a3d2b261366si1205649ejb.664.2024.02.17.16.44.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 16:44:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70125-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="T/xwhoLJ"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-70125-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70125-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 6863A1F21A97 for ; Sun, 18 Feb 2024 00:44:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AD0117F8; Sun, 18 Feb 2024 00:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T/xwhoLJ" Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (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 151D9A29 for ; Sun, 18 Feb 2024 00:44:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708217060; cv=none; b=Ed1pQsTU13CM/TjjejxmfplrXf2EUffvjO14Dr2j2gfjD79BGdYOETWqacgVDBzvsaCohaiJzPw6YCm/LoUEaWOeSJfLbxNyxe17yB+6ZemuWqasJUIYAawssJhHgM9CKZLHcAudM0nA+/sc4qKp7cjdR+SDKxBdlqdtZtOevwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708217060; c=relaxed/simple; bh=eObXZNCrhmMoAtoJx0M+KCXazEG8uiFRYjucowDmnr4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FUdT4WnQ42Nqb3p2qSymItbUjxgGt3GOEuHgFBuuSK0SoW7ddS6B0q6EsXAw9v1QlbUDU9ug/toBu6WHJy4BUrMykoH30YIZGBp6eTBRTi1Wwfpged3Hgj/bMeo070KhGjoYKmPV6bYO8yT0hqiUMSv7aS2T8ct3HPwtS2ULXiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=T/xwhoLJ; arc=none smtp.client-ip=209.85.128.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-60802b329c4so18457487b3.0 for ; Sat, 17 Feb 2024 16:44:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708217058; x=1708821858; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cFEGcM8EospHG4JmqyUXYLdSoH1Alzf1U0lPv6eqJTM=; b=T/xwhoLJPGVdk1V/HhrRgMZsfbN6nYRAHY5lwofz/l8q5zNjsBdJVXHBeS39CuSKox oqZe9CArJF37hHdFcyB5oiFH4ujlXu4RT29aK9L9rAZCvLrzgxNAndKlFHnw4Em75p+K eE/5z2hTbf2OGDYB0xQNRG48TSeSBUr/9TVi5eFpo8xxObEsGC6nEnrLNaYSUIa+x4oD Fe+W3UaU3cJXUBmqIgQ0Fq9wm5jDazohABpGuT1uZ2A6O+/4Atyt1q0Z3BBgfyWd05Uy yWqNIE2qrm1W/0DpZtWfEZFltW6lBPHP4XgwnjDduBKb5WSU3rF9Np+VyvH5zaXEZ//3 viqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708217058; x=1708821858; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cFEGcM8EospHG4JmqyUXYLdSoH1Alzf1U0lPv6eqJTM=; b=ITKtRh8G+ypcBhpiaU6xcOhVDF3z44L5HMcqUytteM85wksmOuEzsmYeaYQVUxyTZe UhSt2Z7qpTVKxJOOs3mei6U0wZAXE5wRLo9S7RBKlAo45qCUavYvOdgkELAEy3DIc5GG xbmsIXhqGV4nuBm8vXsLwvDP5RJpgGGBI94vN5F8SFqh8TRSy/Ky6Ad6fYStR2HYCQOI a4WUkzIRRU66e7TXqWZZMFE0Km0p4nsYFWgne38IOz4t0ANVoIhRXIuDzbOWA/CFMj0z pj5b2mFIc3vc1ui+F2aCsAySZcCsbx+RgzE+PI35VpME/LximCbWt4Yc+BfnNlPl8ZDA e3FQ== X-Forwarded-Encrypted: i=1; AJvYcCUEtfjphOEQ61YWnzn2NTIdCgylb+KFiNAyEZMkzOyYWgC2hm5mHgqKGLEIxI2En4fjYiAyfo+ato085eDHf5QUTz1nPs7vFQB+e870 X-Gm-Message-State: AOJu0Yxr9NeN3GYwfLeRKyIxGV3km9wX4vO/Jri2SvOUZtUX7EgmVbao /gXu3GWo3/9+A/HzGOOGPPGqQLovMyEmQ3Yy8qtJ5ob9rRjDjuU4gKTxZFqoaJV/5Gyq630cLIe 5mBEiT1D7g4jCQjHKkCjaFLE7Tl7uZbNRDpRK X-Received: by 2002:a81:914a:0:b0:604:f681:a1 with SMTP id i71-20020a81914a000000b00604f68100a1mr9152837ywg.16.1708217057719; Sat, 17 Feb 2024 16:44:17 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> <20240212213922.783301-19-surenb@google.com> <2e26bdf7-a793-4386-bcc1-5b1c7a0405b3@suse.cz> In-Reply-To: From: Suren Baghdasaryan Date: Sun, 18 Feb 2024 00:44:05 +0000 Message-ID: Subject: Re: [PATCH v3 18/35] mm: create new codetag references during page splitting To: Vlastimil Babka 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, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 16, 2024 at 4:46=E2=80=AFPM Suren Baghdasaryan wrote: > > On Fri, Feb 16, 2024 at 6:33=E2=80=AFAM Vlastimil Babka = wrote: > > > > On 2/12/24 22:39, 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. > > > > Wouldn't it be possible to adjust the original's accounted size and > > redistribute to the split pages for more accuracy? > > I can't recall why I didn't do it that way but I'll try to change and > see if something non-obvious comes up. Thanks! Ok, now I recall what's happening here. alloc_tag_add() effectively does two things: 1. it sets reference to point to the tag (ref->ct =3D &tag->ct) 2. it increments tag->counters In pgalloc_tag_split() by calling alloc_tag_add(codetag_ref_from_page_ext(page_ext), tag, 0); we effectively set the reference from new page_ext to point to the original tag but we keep the tag->counters->bytes counter the same (incrementing by 0). It still increments tag->counters->calls but I think we need that because when freeing individual split pages we will be decrementing this counter for each individual page. We allocated many pages with one call, then split into smaller pages and will be freeing them with multiple calls. We need to balance out the call counter during the split. I can refactor the part of alloc_tag_add() that sets the reference into a separate alloc_tag_ref_set() and make it set the reference and increments tag->counters->calls (with a comment explaining why we need this increment here). Then I can call alloc_tag_ref_set() from inside alloc_tag_add() and when splitting pages. I think that will be a bit more clear. > > >