Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1214485rdb; Fri, 22 Dec 2023 20:46:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHq/BJutayhPJnAZNidnUjrDR0ZfShEGhc8UA7FHAP486NIGMmUK80yehbUQUwqQiaz8fLf X-Received: by 2002:a05:622a:2485:b0:425:88d5:e487 with SMTP id cn5-20020a05622a248500b0042588d5e487mr4163168qtb.50.1703306787639; Fri, 22 Dec 2023 20:46:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703306787; cv=none; d=google.com; s=arc-20160816; b=IsogDuxZ9x2AlsMaK6rXiCikI7+/Bwc6HWteZGhOQxDM6xzLa5bhbMbWAdFzfGdcPO pr0OWR+xxKnXsjAc0TL+TPtum8yegMfikvuCsbhLzFueewoP/uwcOzRD1I/bBllX99r8 9z7lBtHTameEkgNTVVBkhQPhsBWaphHOftG43znYUOuiwGyI6obWysbdbNAxd2MZNRp0 rKEVgFBcsGdiBLsquq9C1AsGNhl+NxjU7lXX2n6XICIToEnZ/x6fdZVHkgBm6BBbBDaL l/++v5VVFlbE799d+J5qr1o5J6CMsKnuv++o+SeKyJOnD11xd/luOjlx6NY1uio2AJxr 2t2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BoDmPVS6ryId1Ndy9LNLIvaAlql/jHh5ljsjLKW2LUQ=; fh=274XMWnor9Hb+k6pYYUUFT029wxkd23QqV1NgBdZL04=; b=tGx3PsuASEebQzBkQFHHDPCFrcl5YbZaXKN8al/S3kS5iQVeGSkhu/FGVwTn5QNiW2 rltkiz27ctAnWe2T+6r8qu+pGZBdzPsUur9ZRSzVj4A6k1key6Fr62fkueVTBFFnGDBh M2jITh0s+IurstQTRwlqwQ1pqJbdz9kg9Ihhx4dTRHJT+1W9veMDSKglp069YJYYuMqe 6/JtVW6YxXCXud4bJKWbsWxUaPPj1KmEiY0qA0mHyVoHW3gBUi2J7BqbZ+1GLniI/bm1 S4KwXm2OjjdK3kfjbGF2s+89aEuu02DuSroy7/Jvtl/RYjfh+awkOgSkoKO4hGoAZgs8 D4lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XA7GeR34; spf=pass (google.com: domain of linux-kernel+bounces-10288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10288-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f15-20020ac85d0f000000b004274fd2c983si6083688qtx.733.2023.12.22.20.46.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 20:46:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XA7GeR34; spf=pass (google.com: domain of linux-kernel+bounces-10288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10288-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 634381C221B0 for ; Sat, 23 Dec 2023 04:46:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1A095381; Sat, 23 Dec 2023 04:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="XA7GeR34" X-Original-To: linux-kernel@vger.kernel.org Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDE5E46A2; Sat, 23 Dec 2023 04:46:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=BoDmPVS6ryId1Ndy9LNLIvaAlql/jHh5ljsjLKW2LUQ=; b=XA7GeR34AQ1sEHRKpLPEfIWkvw 95V4/LUiY0glq+hos8RQbJbObvWwotsc42i0s8HtQAKMV1CnrAj51LhLYmrwv3loMGQ82pjaVtDzy sUecbuul7gISNrsiCGG2Ru/11OXVdkMSk7YhKNxgmKvhS19fINbutN89VqcgzAjplLh5MMgrwjpFl QBe3W8QoOytAbHjh7VeH9Y1BwnDooJ5AqHWDJjDu75kYln121NpYu9r9HgGwe7b63ABsWXEzosY9T 4m0knNig6lmNyOreYULUJ3hPZYQ/hHLdwYKvsbF4sd4m792N4OFes+2LeqTP7wMoBqwqm73vx+edn ejt+ebBw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rGtts-009rnh-F2; Sat, 23 Dec 2023 04:46:12 +0000 Date: Sat, 23 Dec 2023 04:46:12 +0000 From: Matthew Wilcox To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, Linux Kernel Mailing List , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 5/8] fs/ntfs3: Use kvmalloc instead of kmalloc(... __GFP_NOWARN) Message-ID: References: <890222ac-1bd2-6817-7873-390801c5a172@paragon-software.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <890222ac-1bd2-6817-7873-390801c5a172@paragon-software.com> On Mon, Jul 03, 2023 at 11:26:36AM +0400, Konstantin Komarov wrote: > > Signed-off-by: Konstantin Komarov So, um, why? I mean, I know what kvmalloc does, but why do you want to do it? Also, this is missing changes from kfree() to kvfree() so if you do end up falling back to vmalloc, you'll hit a bug in kfree(). > +++ b/fs/ntfs3/attrlist.c > @@ -52,7 +52,8 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct > ATTRIB *attr) > > ??? ?if (!attr->non_res) { > ??? ??? ?lsize = le32_to_cpu(attr->res.data_size); > -?? ??? ?le = kmalloc(al_aligned(lsize), GFP_NOFS | __GFP_NOWARN); > +?? ??? ?/* attr is resident: lsize < record_size (1K or 4K) */ > +?? ??? ?le = kvmalloc(al_aligned(lsize), GFP_KERNEL); > ??? ??? ?if (!le) { > ??? ??? ??? ?err = -ENOMEM; > ??? ??? ??? ?goto out; This one should be paired with a kvfree in al_destroy(), I think. > diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c > index 107e808e06ea..d66055e30aff 100644 > --- a/fs/ntfs3/bitmap.c > +++ b/fs/ntfs3/bitmap.c > @@ -659,7 +659,8 @@ int wnd_init(struct wnd_bitmap *wnd, struct super_block > *sb, size_t nbits) > ??? ??? ?wnd->bits_last = wbits; > > ??? ?wnd->free_bits = > -?? ??? ?kcalloc(wnd->nwnd, sizeof(u16), GFP_NOFS | __GFP_NOWARN); > +?? ??? ?kvmalloc_array(wnd->nwnd, sizeof(u16), GFP_KERNEL | __GFP_ZERO); > + > ??? ?if (!wnd->free_bits) > ??? ??? ?return -ENOMEM; > This one with wnd_close() and of course later in wnd_init(). > diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c > index da739e509269..0034952b9ccd 100644 > --- a/fs/ntfs3/super.c > +++ b/fs/ntfs3/super.c > @@ -1373,7 +1373,7 @@ static int ntfs_fill_super(struct super_block *sb, > struct fs_context *fc) > ??? ?} > > ??? ?bytes = inode->i_size; > -?? ?sbi->def_table = t = kmalloc(bytes, GFP_NOFS | __GFP_NOWARN); > +?? ?sbi->def_table = t = kvmalloc(bytes, GFP_KERNEL); > ??? ?if (!t) { > ??? ??? ?err = -ENOMEM; > ??? ??? ?goto put_inode_out; And this one with ntfs3_free_sbi()