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 A2E28D20683 for ; Tue, 15 Oct 2024 22:59:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 302C16B007B; Tue, 15 Oct 2024 18:59:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28BB76B0082; Tue, 15 Oct 2024 18:59:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12D746B0083; Tue, 15 Oct 2024 18:59:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EAC1D6B007B for ; Tue, 15 Oct 2024 18:59:39 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1B564AAA9C for ; Tue, 15 Oct 2024 22:59:21 +0000 (UTC) X-FDA: 82677354816.20.E2D098E Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 605721C000C for ; Tue, 15 Oct 2024 22:59:34 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="0bK+bo/u"; spf=pass (imf18.hostedemail.com: domain of surenb@google.com designates 209.85.160.172 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=1729033033; 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=aatrfRIq+KwjGDMApdNFzlbuQ/dlgztbUi1A7FhVako=; b=TlnbubaP9nsrKGY9nYh+99EYxdF1+qLTQC1hM+ICm/8KejHsE414+V13IvTv3Bl5TmsC1W 8zZyXYi2mNmoie7TnubTCJeQOgU21YBVQwqtoydheo/QlJsolcG011wdIH7ZuRr3liPE5j Oace0TnYu6xFImfBvOCyQbYzixcsX3E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729033033; a=rsa-sha256; cv=none; b=KIBJ8tppbTpckFgqwLQWwEMnx2RFM+vR5y9DbVlBlYlDpHbeMB13/mYGOHOKI5WEBedhia 3VE+OvckZrUQAcTPSItm905XZBIcAfUSR7Cs5U2FBlw0shDFut8CBqtn9sZyDvGPX432Cd at5B435OLnbCuN61pOyXFgDyVELPeQ4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="0bK+bo/u"; spf=pass (imf18.hostedemail.com: domain of surenb@google.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-4601a471aecso26301cf.1 for ; Tue, 15 Oct 2024 15:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729033177; x=1729637977; 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=aatrfRIq+KwjGDMApdNFzlbuQ/dlgztbUi1A7FhVako=; b=0bK+bo/uCS2t1Ds+QdfPmcA2uM5Y3tHN5YkvA3BE8J+SpkuEaNL/zSSZwVdemCIKW5 8D8xGx5AP+BKIgLyDFIePklLiayWPtstbdk8BdXruvnub9LLvjh+ZLV02Cs5z+b032o9 xltNeWib0GDLW1EMlxXnbCXs3sY+OYPDfz+UyPKwglwGZrAroBhb64UobRunnk4WU0Sa 06Q7PlwO21kUrDBnh/AZi/HBE2JwvebO/d56BX58BO6AAJQftIFfx5w6AiuTzrh0Cgzf eKTs1dIRdZH3d7iNyYewuCEFmoShWEmvuvg/aXzOk4NBUZTiIXTeAx5gfT0HGxYPdDaa SRwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729033177; x=1729637977; 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=aatrfRIq+KwjGDMApdNFzlbuQ/dlgztbUi1A7FhVako=; b=Et8/fATR2Y0DpO6UxHJQH9RUfOcrvtTx7LAVtPeLF83eZZ/FzyNPlbB2gLp1DHZ8St aytSu5P/KnMgb4V7NqR7vIjdF+pEDrSCWKfZUK5AfQsnrrW24ByR0LKKgDQHN5cmFPC4 bSn4su60Ew20kFN3TpMn2tgJKGIrtWJRtJYLy4bkj1Mt8xW04L8KzK+jKHV9Xi0lNINk NiDLhgB/sZUxuPXXp3NQ2ZCalxYATk5IFZfQ+oX+b4aKXy/jS4yqSOYxRP2cKbRM9Qw2 /or74cC3+LZeMVDSgPdyhRwbp3vblQ7f2sTwEsPtKifol3cCKFWwQK40U3Lqfce/oU6h k1LQ== X-Forwarded-Encrypted: i=1; AJvYcCUbdR+/QwvbBJFJzbZlBaQ414gLIZd4N0HenWrf9KSP1mA8PRuJoSonMQNFH+SKAcp2mscQ5aUAVQ==@kvack.org X-Gm-Message-State: AOJu0Yx32t4FgaAYfUMULiXKzWMQdSEcEs55AermRSGTEXLivewfQ0KN 76l4iXDJnzY+n2BNloEVRgunRaVUMjSgpI5amJGtAlByc6YTxYH6p5fXCWyJor4yiCtmAo8+/XX Ny0h+8JvfFq1oMeSV1KyCKsR7/qWNyLotIAvB X-Google-Smtp-Source: AGHT+IELTeVk+3ZUTk+NpnVTeDJUGBGjLAiZXyLrgAjXmAsx+E8kO4d8VubcdugaUnODGJwHhuL8CSe4MgIy4xCWvP4= X-Received: by 2002:a05:622a:46cb:b0:45c:9d26:8f6e with SMTP id d75a77b69052e-4608ed29b69mr572131cf.21.1729033176389; Tue, 15 Oct 2024 15:59:36 -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: From: Suren Baghdasaryan Date: Tue, 15 Oct 2024 15:59:23 -0700 Message-ID: Subject: Re: [PATCH v3 2/5] alloc_tag: load module tags into separate contiguous memory To: Shakeel Butt Cc: Andrew Morton , 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: 76swd8wr7hxf638zusqgxtd571pgukcm X-Rspamd-Queue-Id: 605721C000C X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729033174-924273 X-HE-Meta: U2FsdGVkX194xgQdSidx5YVAofNFCMrXFIfA3CVSgTroBp8zAi6D83sMAWyCsYHrsBCYkngTIgA6YeIrywkECDXssSVLNwCoLeuQH7wGj0gTqsk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fxT9xadJ3cHn4vOgCP3Cosa/EuY39wxVq3DDD19b+PIMlJ13s+Q7WyjRqLFdQUb+YhC0fXXM1xQ1AJg4d+wMB6fpYvqQ6ILoNDOaCna3XLbVO9Hb9RvqA+8EUISob2pUJD8zvKbCbomnaU= 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 Tue, Oct 15, 2024 at 2:08=E2=80=AFPM Shakeel Butt wrote: > > On Mon, Oct 14, 2024 at 07:10:56PM GMT, Suren Baghdasaryan wrote: > > 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 tag= s > > > > corresponding to these allocations are still referenced. As such, t= he > > > > 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 in= to > > > > their own separate memory. The in-use memory areas and gaps after > > > > module unloading in this separate memory are tracked using maple tr= ees. > > > > Allocation tags arrange their separate memory so that it is virtual= ly > > > > contiguous and that will allow simple allocation tag indexing later= on > > > > in this patchset. The size of this virtually contiguous memory is s= et > > > > 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 modul= e *mod, enum mod_mem_type type) > > > > return 0; > > > > } > > > > > > > > -static void module_memory_free(struct module *mod, enum mod_mem_ty= pe type, > > > > - bool unload_codetags) > > > > +static void module_memory_free(struct module *mod, enum mod_mem_ty= pe type) > > > > { > > > > 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 i= n > > > mm-unstable. I assume Mike is working on a v2 so I'll park this seri= es > > > 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. > > 6.12 or 6.13? Right, it's 6.13 at this point.