Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp693229lql; Mon, 11 Mar 2024 14:42:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUxkYwrn7fMcSSPeabv5V1NSY6APtUQF7P4DjMRMFe0k9/CqaQ8u3eyyfM9MHIhpkEQU8dkJOMr5EHyBeirTepsk6VtNYU+Vt3Lw1IBQ== X-Google-Smtp-Source: AGHT+IEDe+IFXHzChvYPqNqPYUw4f/PCVtWRa/711thSTYKj56y1YRxLoI2yd03Kx0+EP7QUzp3i X-Received: by 2002:a50:ab15:0:b0:566:1794:7b2 with SMTP id s21-20020a50ab15000000b00566179407b2mr1224124edc.13.1710193377192; Mon, 11 Mar 2024 14:42:57 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n10-20020a50934a000000b005682c245250si2782975eda.13.2024.03.11.14.42.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 14:42:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-99575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id E6D041F219AA for ; Mon, 11 Mar 2024 21:42:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1442057301; Mon, 11 Mar 2024 21:42:47 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (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 BD18A56B6A for ; Mon, 11 Mar 2024 21:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.85.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710193366; cv=none; b=R2rvPrih7wuW0YMAJJDU1mWWdRJKKemRyMvzx5QfLFlAbsUcmgi05QNQir4agGo18GXR3ftSMxUn54K/saMrrVp63psIoLNVVNM/uGzJxz9cve4LRTFgQ6a4F4wfloqaoVdvw8+mLMp1f2Szb3IxNd7WyJxMI4PV0Pcwzj7vBOs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710193366; c=relaxed/simple; bh=GQXaXyc1zQJyIJwVtjwpKqnlF5O4YH+/iBVavsbfGpY=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=h+nCBNWtAPykV0KUYFW0hsjuOYRTXIdYNW4gONcWJILSe4MAlt4P7SUTkcrc4OZ/bgi+tSpYDQl8DO8Gbcv5WQraKBed64FAFX0RZPDjNSDmipKBFrRRJgmE18nUqGnN0INfJ1icLEPXyPaQyAVSDv6fLftz7MJwzoUqL83PCSc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.85.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-182-1CQnVePBPnqOGYOB4eHJow-1; Mon, 11 Mar 2024 21:42:41 +0000 X-MC-Unique: 1CQnVePBPnqOGYOB4eHJow-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Mon, 11 Mar 2024 21:42:46 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Mon, 11 Mar 2024 21:42:46 +0000 From: David Laight To: 'Matthew Wilcox' , Dave Chinner CC: "linux-mm@kvack.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: On the optimum size of a batch Thread-Topic: On the optimum size of a batch Thread-Index: AQHac2YDWJ9ZLWk00E2JGYCnzpWSgrEzDvkw Date: Mon, 11 Mar 2024 21:42:46 +0000 Message-ID: <5c54bfe5123f4e6390400599427c23b7@AcuMS.aculab.com> References: In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Matthew Wilcox > Sent: 11 March 2024 03:42 .. > But that doesn't necessarily mean that you want a larger batch size. > Because you're not just allocating, you're also freeing and over a > large enough timescale the number of objects allocated and freed is > approximately equal. In the SLUB case, your batch size needs to be > large enough to absorb most of the allcation-vs-free bias jitter; that > is if you know they always alternate AFAFAFAFAF a batch size of 2 would > be fine. If you know you get four allocations followed by four frees, > having a batch size of 5 woud be fine. We'd never go to the parent > allocator if we got a AFAAFFAAAFFFAAAAFFFFAAFFAFAAFAAFFF pattern. That isn't really the allocation pattern you need to worry about. Per cpu free list should be large enough to handle it. The problem (as the first people doing a sparc SMP port found) is that you'll get one bit of code that 'pumps' items from one free list to another. So you have to decide that you have too many local free objects and then give some back to the global free list. Keeping them on the global list as a block of 'n' items can make things far better. Indeed 'arrays of pointers' are likely to be better than a linked list. Caches in front of SLUB (or similar) really shouldn't be needed. Except, perhaps, to indicate which list the items come from and, maybe for some extra allocation stats. There might be rcu oddities - where the memory can't be used for a different structure. But there are probably alternative solutions to that one. The page free code is a different problem. I suspect that needs to process batches of items to avoid repeated (expensive) atomic accesses. But it definitely needs to avoid thrashing the L1 cache. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)