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 DA8CECFC505 for ; Tue, 15 Oct 2024 02:11:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 740036B00A0; Mon, 14 Oct 2024 22:11:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C7C76B00AA; Mon, 14 Oct 2024 22:11:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 541D46B00AC; Mon, 14 Oct 2024 22:11:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 305276B00A0 for ; Mon, 14 Oct 2024 22:11:10 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 61F74AC1DD for ; Tue, 15 Oct 2024 02:10:53 +0000 (UTC) X-FDA: 82674208806.08.FDA5E66 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by imf25.hostedemail.com (Postfix) with ESMTP id 73D50A0004 for ; Tue, 15 Oct 2024 02:11:03 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lPK3U6Nh; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728958125; 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=e4d393RqsyL/BJ4Co9qwq0LGbkJ+IqpYMBLpcbUgTRI=; b=1MtiA0UfoQWyMgFQ+40eRiXAqAYZsraBmoKwzhmSmXdR1EgKjPDFq3f40jGgMy+FlpQg6e ndgBMc2wN+UvaScHy7fHwU4OfGWFKDc6dqHTC6ouCqBCAZlRORUSjEBljwb1Je+mvxOnuL xKC5g1saTR2Kf6PDOYxITVBXp0T6pzY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728958125; a=rsa-sha256; cv=none; b=PnPx7HzvT7TJ4lHDkW776lJ3QvtOPNY4w8l004ib4ccHvF2zenGHQniP4vyEaYKkDXbjtR TxfUlA8Ge0w5RdDAreohoUBFyLttFRcFpuDvxndYEMFlj3ZSVhnPxs/PcpqYjATjbR/yxO Tk9CDACXNBg/kqfO6Uk90WGrp4VcdEQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=lPK3U6Nh; spf=pass (imf25.hostedemail.com: domain of surenb@google.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-460395fb1acso577531cf.0 for ; Mon, 14 Oct 2024 19:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728958267; x=1729563067; darn=kvack.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=e4d393RqsyL/BJ4Co9qwq0LGbkJ+IqpYMBLpcbUgTRI=; b=lPK3U6Nh6GKZpOoZeGLFY7jLtmhSDSknRpSYmOU1kl0F4spqNbbmjPwoA7zR3uy19+ NCLdJ2owHCKCVi98ulYVDUtbGVd/JbQ+VOpqb7db5eIY+8BGQlGFK1UcEayYsnqcbCPg HQwtBdtC+PQdiOcHnTYA/bQNJdjjmnyCO6c/X970z46k6lyP1DiGPmVxAKtP69OiPz/i bzEmrlSPGdaQTXpWGD539lkjpdU7EpBIoDl2wFj7GeRq1eQsz1VfDfUiafXptd4/sxB+ QIO2NM83qntZ4jp5eTeCm/ZWa0nVC8DeGUx9e5NA1FoAmOs5q24tBSTfbzuYUePr8jL8 dDcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728958267; x=1729563067; 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=e4d393RqsyL/BJ4Co9qwq0LGbkJ+IqpYMBLpcbUgTRI=; b=WlQuXQVlF6r8/Id/JSPDll21pSvY6WK9A0FyijpW/yB3uPq+K4yPpgwjfH5GBKc/6g VhR1NDgbGKpj8397YInCMqU6qQwmFdLAGfZlryE+mnDTQFk+VlKDZz5R20/WvRM6GRjg scYPUshbdMVlCEGo97UEawnX0PZjOKIW7GeFhbZGZppdB0M5LUWo23PhNeeyUOjFY0dB 403+Ds5u/+cON1vXns0K02xpoAKowefj7pnHoBM84D4+uTro2ZXhzKkhysbJh11ZAqoN +Ps6S1y9Y24GKspHN9EKbfHQ0VERtZq7vsN+e1GNbw06f/vrmbu7k2sz4OcRiPJsRdC1 LlAQ== X-Forwarded-Encrypted: i=1; AJvYcCX6X3T0tL103oes5GL5UVHSLK77oq1LfDbe+efKp0CibmpBBoeONLYGMLj1wjrBpM3PjMg2mXF+wQ==@kvack.org X-Gm-Message-State: AOJu0YwqktPkklKyp7Tcw3T/fUlLhHXVFLSzOpGnR4OnOQYvwCuGivcS 4hu9S1BmBtqaWGtRtmzL6ljaB6VmWwh/B7ZDVCvKq2V2ktwQZKgP08i6TvYXq68Z8MAuEBWhSty FVduLaCuDWIlcmNNZK9fvml8CZh/I+9nhaAKK X-Google-Smtp-Source: AGHT+IH2LRfRBm57PdBw/tS8q8+UtN+Kyr0mTZGba3MM4WXhOw4k5NEo7Tk1C6FhBp0+hTMOPWmhXG8Ppv2xTgArgLA= X-Received: by 2002:a05:622a:5b8a:b0:460:4777:b060 with SMTP id d75a77b69052e-46059c777b6mr6458551cf.27.1728958266985; Mon, 14 Oct 2024 19:11:06 -0700 (PDT) MIME-Version: 1.0 References: <20241014203646.1952505-1-surenb@google.com> <20241014203646.1952505-3-surenb@google.com> <20241014165149.6adebbf38fdc0a1f79ded66b@linux-foundation.org> In-Reply-To: <20241014165149.6adebbf38fdc0a1f79ded66b@linux-foundation.org> From: Suren Baghdasaryan Date: Mon, 14 Oct 2024 19:10:56 -0700 Message-ID: Subject: Re: [PATCH v3 2/5] alloc_tag: load module tags into separate contiguous memory To: Andrew Morton Cc: kent.overstreet@linux.dev, corbet@lwn.net, arnd@arndb.de, mcgrof@kernel.org, rppt@kernel.org, paulmck@kernel.org, thuth@redhat.com, tglx@linutronix.de, bp@alien8.de, xiongwei.song@windriver.com, ardb@kernel.org, david@redhat.com, vbabka@suse.cz, mhocko@suse.com, hannes@cmpxchg.org, roman.gushchin@linux.dev, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, pasha.tatashin@soleen.com, souravpanda@google.com, keescook@chromium.org, dennis@kernel.org, jhubbard@nvidia.com, yuzhao@google.com, vvvvvv@google.com, rostedt@goodmis.org, iamjoonsoo.kim@lge.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: edtsd5ry9uu9w78e4x46773p9fscqmzg X-Rspamd-Queue-Id: 73D50A0004 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728958263-425160 X-HE-Meta: U2FsdGVkX19Od9akA0icI72Veq5Tz9L1ngwBhfkvmZgTZYC0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3E/zrJycysxAh4cM/ImjnsKdXEKWzyhnmGHA88sxkU/eX+E/eGgD4pzlIHCIIj9rugq8f5yYBLRElf9RTV+DTIKPovYzcSrg1MIeg/P5M9qq6MxhV55Q3Ek5Q38tMe8Y9sW7rxF7Ct7yk1wt+rUMnrhmyhyKZwRhtkqwiX5b2l3r4tkVw0UTdeyJZsOTUQBIXPZF68vrQa2EWJGENukGuIJEbCTKowI24= 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 Mon, Oct 14, 2024 at 4:51=E2=80=AFPM Andrew Morton wrote: > > On Mon, 14 Oct 2024 13:36:43 -0700 Suren Baghdasaryan = wrote: > > > When a module gets unloaded there is a possibility that some of the > > allocations it made are still used and therefore the allocation tags > > corresponding to these allocations are still referenced. As such, the > > memory for these tags can't be freed. This is currently handled as an > > abnormal situation and module's data section is not being unloaded. > > To handle this situation without keeping module's data in memory, > > allow codetags with longer lifespan than the module to be loaded into > > their own separate memory. The in-use memory areas and gaps after > > module unloading in this separate memory are tracked using maple trees. > > Allocation tags arrange their separate memory so that it is virtually > > contiguous and that will allow simple allocation tag indexing later on > > in this patchset. The size of this virtually contiguous memory is set > > to store up to 100000 allocation tags. > > > > ... > > > > --- a/kernel/module/main.c > > +++ b/kernel/module/main.c > > @@ -1254,22 +1254,17 @@ static int module_memory_alloc(struct module *m= od, enum mod_mem_type type) > > return 0; > > } > > > > -static void module_memory_free(struct module *mod, enum mod_mem_type t= ype, > > - bool unload_codetags) > > +static void module_memory_free(struct module *mod, enum mod_mem_type t= ype) > > { > > struct module_memory *mem =3D &mod->mem[type]; > > - void *ptr =3D mem->base; > > > > if (mem->is_rox) > > vfree(mem->rw_copy); > > > > - if (!unload_codetags && mod_mem_type_is_core_data(type)) > > - return; > > - > > - execmem_free(ptr); > > + execmem_free(mem->base); > > } > > The changes around here are dependent upon Mike's "module: make > module_memory_{alloc,free} more self-contained", which is no longer in > mm-unstable. I assume Mike is working on a v2 so I'll park this series > for now. Looks like the last update on Mike's patchset was back in May. Let me check with Mike if he is planning to get it out soon. I would like my patchset to get into 6.12 if possible. Thanks, Suren.