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 83DAEC433EF for ; Tue, 8 Mar 2022 17:10:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2B2D8D0005; Tue, 8 Mar 2022 12:10:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CDA058D0001; Tue, 8 Mar 2022 12:10:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC9C28D0005; Tue, 8 Mar 2022 12:10:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id B00368D0001 for ; Tue, 8 Mar 2022 12:10:50 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 672132498F for ; Tue, 8 Mar 2022 17:10:50 +0000 (UTC) X-FDA: 79221858660.07.7B50DB8 Received: from forward501j.mail.yandex.net (forward501j.mail.yandex.net [5.45.198.251]) by imf23.hostedemail.com (Postfix) with ESMTP id 20868140004 for ; Tue, 8 Mar 2022 17:10:48 +0000 (UTC) Received: from myt6-08ca0b879dee.qloud-c.yandex.net (myt6-08ca0b879dee.qloud-c.yandex.net [IPv6:2a02:6b8:c12:12a2:0:640:8ca:b87]) by forward501j.mail.yandex.net (Yandex) with ESMTP id 696E56231E7; Tue, 8 Mar 2022 20:10:46 +0300 (MSK) Received: from myt6-016ca1315a73.qloud-c.yandex.net (myt6-016ca1315a73.qloud-c.yandex.net [2a02:6b8:c12:4e0e:0:640:16c:a131]) by myt6-08ca0b879dee.qloud-c.yandex.net (mxback/Yandex) with ESMTP id Fr4iNMSee3-AjfS99Dp; Tue, 08 Mar 2022 20:10:46 +0300 X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clicknet.pro; s=mail; t=1646759446; bh=t6DJaX0QMCymVmpbwbgGIxCSqo6kOF3LEc2q2uOO4Vk=; h=In-Reply-To:References:Date:Cc:To:From:Subject:Message-ID; b=nZF3wqZWNp9z1OO2Jn0WujJiuko/Ys7MZoPgsXAWd2b6hLy1ESj0xXk1wPjeRyT2B slF4Kakb+ebMUVo4faxpVtBb50qUed16tIBfQRng7XmfoY2gY/EvTv0G5SoEQ7olfY aSVeR2IMtGD4El5YxM2K2Av6wtwWLe1Jso7F9HOg= Received: by myt6-016ca1315a73.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id vVO32AniyC-AjJSfBcU; Tue, 08 Mar 2022 20:10:45 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Message-ID: Subject: Re: [PATCH v3] mm: add ztree - new allocator for use via zpool API From: Ananda Badmaev To: Matthew Wilcox Cc: linux-mm@kvack.org, vitaly.wool@konsulko.com, vbabka@suse.cz, akpm@linux-foundation.org Date: Tue, 08 Mar 2022 20:10:45 +0300 In-Reply-To: References: <20220307142724.14519-1-a.badmaev@clicknet.pro> <8255c6882aa7f78e6855cf4adda66afe0c1df809.camel@clicknet.pro> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 20868140004 X-Stat-Signature: xswx3n4gbjdc1389tp7toty9uuntz4z7 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=clicknet.pro header.s=mail header.b=nZF3wqZW; spf=pass (imf23.hostedemail.com: domain of a.badmaev@clicknet.pro designates 5.45.198.251 as permitted sender) smtp.mailfrom=a.badmaev@clicknet.pro; dmarc=none X-Rspam-User: X-HE-Tag: 1646759448-564409 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: В Вт, 08/03/2022 в 15:40 +0000, Matthew Wilcox пишет: > On Tue, Mar 08, 2022 at 06:16:35PM +0300, Ananda Badmaev wrote: > > > Hm.  So 368 bytes on 64-bit, but 372 bytes on 32-bit?  Is that > > > intentional?  Why 11? > > > > > Yes, 'slot_size' and 'slots_per_block' values are chosen so that in > > general the range from 0 to PAGE_SIZE is split more or less evenly > > and > > the size of the block is as close as possible to the power of 2. > > Also > > 'slot_size' values are aligned to the size of long. > > Is it intrinsic to the design that the blocks are aligned to > sizeof(long)? slot_size values must be aligned so that the slot addresses in blocks are also algined to avoid potential problems with unalinged access. I guess 4/8 byte alignment is enough for 32/64 bit systems respectively. > > > > > > You have some very strange indentation (throughout). > > > > > I was trying to limit the length of lines. > > But you didn't achieve that.  The _start_ of the line containing > block_type and gfp was _more indented_ than the end of the previous > line.  Do you have unusual tab settings? > Maybe it's because I have tab size 4 in my editor. > > > thinking > > > about it".  What if you have two threads that execute this path > > > concurrently?  Looks to me like you leak the memory allocated by > > > the > > > first thread. > > > > > Probably I should pass GFP_ATOMIC flag to alloc_block() and execute > > this entire section of code under single spinlock. > > I think that's a bad approach.  Better would be: > >         spin_lock(); >         if (free_slot_block) >                 goto found; >         spin_unlock(); >         block = alloc_block(); >         spin_lock(); >         if (free_slot_block) { >                 free_block(block); >                 block = free_slot_block; >         } else { >                 free_slot_block = block; >         } > found: >         ... >         spin_unlock(); Yes, seems really better to do like this. Solution with GFP_ATOMIC probably will improve the worst time of ztree_alloc(), which was not big issue in the tests, but most likely general efficiency will be degraded.