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 2DAC0D18157 for ; Mon, 14 Oct 2024 23:51:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD5B16B0089; Mon, 14 Oct 2024 19:51:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A86BA6B008A; Mon, 14 Oct 2024 19:51:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94D2F6B008C; Mon, 14 Oct 2024 19:51:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 752EF6B0089 for ; Mon, 14 Oct 2024 19:51:55 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EB8A9C1318 for ; Mon, 14 Oct 2024 23:51:45 +0000 (UTC) X-FDA: 82673857896.19.EF6E3E8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id ED6351C0012 for ; Mon, 14 Oct 2024 23:51:44 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=y763ME0M; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728949724; 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=kQ5PqrM2ukjsXnX2qciB16scoUX4QhAhFQhQtxHOeDA=; b=S1Uz51KvujleBTMU+dzEnZ99PDf+o8uOIcD2rLZwQbyveiLGOm+vU9UjTy63y7QLgzd0Mi 71dHgXjgW687Kh5TdB5z06X6GBLSinhNWJvD5s+c/AzNyqWJhgnyeWJ9Ve/Vq1lb2qC9IH ngKXQ0XQ+3YwwAPXAKJN2TEB9u1R+PA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=y763ME0M; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728949724; a=rsa-sha256; cv=none; b=FcakBir5+td1VkyXg3Ty9Vw+RhCgHXoUtvwlFox5CM/5TtjkXrrq0WL5QKG9Y0MisgxCcI kjBqPo/boD0lNfkY7i8cnc33HTw0jOZ0n+dwCITh7+Z3pxueU0W0VQX5DZu/hZDiZSQSwD OukWMtAa17g5lPya9NBoByU8EFAC84A= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5AF905C5903; Mon, 14 Oct 2024 23:51:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08F9BC4CEC3; Mon, 14 Oct 2024 23:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1728949911; bh=KgzcYqc6OO3pPM2hE/qABbrdsOC02YOymz+D9PyZLYU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=y763ME0Mn/BHTBBvI/yRtJ0VvlbBiA8zFXkt99wodSbTyE0cwElsvzJV4z8mGRm1b l4gQnpIK9Ujvb55nlE5zoNHwY/+AncYm50laP+SHzxuvUCYtniteKU42ECI5PBbHHh tiZDckT6VbsK7j2bTcAAmwIz1+mcqm9EQ1TfDWkM= Date: Mon, 14 Oct 2024 16:51:49 -0700 From: Andrew Morton To: Suren Baghdasaryan 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 Subject: Re: [PATCH v3 2/5] alloc_tag: load module tags into separate contiguous memory Message-Id: <20241014165149.6adebbf38fdc0a1f79ded66b@linux-foundation.org> In-Reply-To: <20241014203646.1952505-3-surenb@google.com> References: <20241014203646.1952505-1-surenb@google.com> <20241014203646.1952505-3-surenb@google.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: ED6351C0012 X-Stat-Signature: czkyoinsj6hz37i5a6hfi8ejqodiprcx X-Rspam-User: X-HE-Tag: 1728949904-315843 X-HE-Meta: U2FsdGVkX19z6r+umiU5AgHeyAJKhCe3fciNUZhMt5GGcVk06ft6CW37mMO6PHhERc2Tj03uKC0/FjiVuRVpGjYr/N+Qh0KMEoqod6eLXtcdib/5gAVdff1WzNUb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aW17l4I6J0h7Q5gtxwLGcRx0CTnYrAhx1FgEOVjYuTE95KDWLODg3sKIeaWmTsD6W7A/suUl8RQt5AEK/1u/rn/a2JUq9R3YxWUUmVuc 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, 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 *mod, enum mod_mem_type type) > return 0; > } > > -static void module_memory_free(struct module *mod, enum mod_mem_type type, > - bool unload_codetags) > +static void module_memory_free(struct module *mod, enum mod_mem_type type) > { > struct module_memory *mem = &mod->mem[type]; > - void *ptr = 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.