Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2310636imc; Tue, 12 Mar 2019 11:07:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1S+qgYt1cgNr07DyycYvRYRXPW3mwDuVhC5WNSpVTSoiA5l7XvlB/h6Ggs8CCQV09Kc4R X-Received: by 2002:a17:902:b111:: with SMTP id q17mr3362697plr.230.1552414030863; Tue, 12 Mar 2019 11:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552414030; cv=none; d=google.com; s=arc-20160816; b=zFYcpA3rF2NGZ7ENwlPbFSYcH5IS7HGXR97A0DrKDLCKxaNO19PBlWDRqBSXIWtMSC W9wvHwOlR3IH1i0GGanPJWOgOY/64ilhtTaDfJmFY5Ld9TSo8l7FkN6WKg5TaLpaN7Jx vg0JA3LoNHWSHxForKUNTm50ghmePSvl4q5PqNqzGGS/dZVvZzADsfbPFxC1KyVP6NOm 6qBj1zeR+R4Ze01op2UkKky1li6ZW7r5kfLg+0OE/z9EPvgfvYMGSwNMwzy5f77a4PAA q9n3gqWIa0IzYrIQK7QWjEFGh6d7t/I25L+x68GvQm9mxC1/mtWIypfBYdD0WSLw34qo qByA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature:dkim-signature; bh=6Ws3AIdbpT34KncUDlT96q/8l4bC8vf7Sa0gpmMAouw=; b=s1e1SuVCLLV4hMTKjCeMFzkRj5F0o5yhmCHsGSsaQjRHTwFHZ+EQcleiwO2mFF+FhK bOWvZGhOmsBgMwMahpX3Pz14NOAm2Hf1jStPk39bch7K8P0S+PFPzoavTBkvrxeRaaWp DbcWWZYar1x/9C7hNAlzuYcWaR9vdslXyzZPIqzgtBcuC+xPWT2vrBHSbIVoRSuJ+eS1 11Yb4Z7yKuYgZjoFcbkY+Kjy4WKgAg9CgImY5lzvZzQmmX0GkoQJ0RPpPZhxBQkzQQp5 Y7pd4/r3l77p9hZNFwieoofCZhT88IFdmvPQj92e8It1GDqc/Lsc9VQ+gA4SUw/1USsP x+hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=ejRv1O3Q; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=KgvJqOeJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si7885638pgb.91.2019.03.12.11.06.55; Tue, 12 Mar 2019 11:07:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=ejRv1O3Q; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=KgvJqOeJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728913AbfCLSFt (ORCPT + 99 others); Tue, 12 Mar 2019 14:05:49 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:54620 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbfCLSFp (ORCPT ); Tue, 12 Mar 2019 14:05:45 -0400 Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2CI2tbv023074; Tue, 12 Mar 2019 11:05:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=6Ws3AIdbpT34KncUDlT96q/8l4bC8vf7Sa0gpmMAouw=; b=ejRv1O3QkHjC2LPTJglsnvuZ2Mv9sEQqLemmivqBQZIVDEHfzDQZVAuxdpR+onFx2M7I R5ecoo1wUvQVMQ2GvMxTSagf9pRNAfOlyx7lB2zhmvY19Bgpzq80Do2KLE/myNgUPSm3 gl2J2ImM94AG5zpI9FDoHZKStSSfF2llHoY= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2r6f6j8xtb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 12 Mar 2019 11:05:28 -0700 Received: from frc-mbx08.TheFacebook.com (192.168.155.29) by frc-hub06.TheFacebook.com (192.168.177.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Tue, 12 Mar 2019 11:00:25 -0700 Received: from frc-hub04.TheFacebook.com (192.168.177.74) by frc-mbx08.TheFacebook.com (192.168.155.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Tue, 12 Mar 2019 11:00:25 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5 via Frontend Transport; Tue, 12 Mar 2019 11:00:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Ws3AIdbpT34KncUDlT96q/8l4bC8vf7Sa0gpmMAouw=; b=KgvJqOeJHy4E4dmODiDb6j5FbkFzjezHKH5QUcHSQlgML9z3iuUgW5g+VLafvSMoRvFYdQsKFCSTVy9RL4TCZPSGaphgsDHEtmMGqCEsd+QnivAdOGcAFnFZp+YPPCgWYm9hoKLHdJZJBgRNzuGKEWfUO0klwzW7aL1yj3jWf/Y= Received: from BYAPR15MB2631.namprd15.prod.outlook.com (20.179.156.24) by BYAPR15MB3159.namprd15.prod.outlook.com (20.178.207.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.19; Tue, 12 Mar 2019 18:00:09 +0000 Received: from BYAPR15MB2631.namprd15.prod.outlook.com ([fe80::790e:7294:b086:9ded]) by BYAPR15MB2631.namprd15.prod.outlook.com ([fe80::790e:7294:b086:9ded%2]) with mapi id 15.20.1686.021; Tue, 12 Mar 2019 18:00:09 +0000 From: Roman Gushchin To: "Tobin C. Harding" CC: "Tobin C. Harding" , Andrew Morton , Christopher Lameter , Pekka Enberg , Matthew Wilcox , "Tycho Andersen" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC 04/15] slub: Enable Slab Movable Objects (SMO) Thread-Topic: [RFC 04/15] slub: Enable Slab Movable Objects (SMO) Thread-Index: AQHU1WWOlMss86oUX0OspYov/G2S1KYGmQIAgACnOACAAQ/MAA== Date: Tue, 12 Mar 2019 18:00:09 +0000 Message-ID: <20190312175958.GA31407@tower.DHCP.thefacebook.com> References: <20190308041426.16654-1-tobin@kernel.org> <20190308041426.16654-5-tobin@kernel.org> <20190311224842.GC7915@tower.DHCP.thefacebook.com> <20190312014712.GF9362@eros.localdomain> In-Reply-To: <20190312014712.GF9362@eros.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MWHPR1301CA0018.namprd13.prod.outlook.com (2603:10b6:301:29::31) To BYAPR15MB2631.namprd15.prod.outlook.com (2603:10b6:a03:152::24) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2620:10d:c090:200::2:d3a0] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 923feb45-9ecd-4b02-534c-08d6a71490cf x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:BYAPR15MB3159; x-ms-traffictypediagnostic: BYAPR15MB3159: x-microsoft-exchange-diagnostics: 1;BYAPR15MB3159;20:+ulgd+cC+WcT4q2RwZ6I8BT1sdE+AfWTOEqCwcBjhMpyRaSFLUTfW/dXSfa+DmWB0yujhw6RsWx3EnwWlvcJW4m0cgJu89YqzkCZLlBObgR3BXgortvpDrlQxnIJeCx93bAZdpsZWzS9dNkp5ZJzqKWhXbtM9jsqBAvQ7dczRF8= x-microsoft-antispam-prvs: x-forefront-prvs: 09749A275C x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(136003)(366004)(396003)(346002)(376002)(39860400002)(189003)(199004)(52314003)(186003)(46003)(8676002)(106356001)(6246003)(81166006)(81156014)(25786009)(33656002)(14454004)(478600001)(6506007)(102836004)(52116002)(386003)(71190400001)(8936002)(229853002)(76176011)(68736007)(6116002)(4326008)(71200400001)(6512007)(9686003)(476003)(11346002)(446003)(53936002)(486006)(6436002)(99286004)(6486002)(2906002)(7736002)(305945005)(86362001)(316002)(14444005)(93886005)(256004)(1076003)(5660300002)(6916009)(105586002)(54906003)(97736004);DIR:OUT;SFP:1102;SCL:1;SRVR:BYAPR15MB3159;H:BYAPR15MB2631.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 05YkwGLcmrv07Rd/Wgqz9MJxu23uFHUInNh2+aJzbtwZOlU8hzCFEof85Pm+35TC+tzqq+YxXztS3x61A+tkYUAwr6MBRItsr28/61dW0YvqQPzH18QIXn2Pr1zYt6zgnTdoDpADAfLWOs5YpSnrpgQTmFbrYw//cR2muwwmBXzt9CwmovqKtEqgy5GBSsd0lP8ZvCly9Cu78XZ8lxAUy30JHCT9U/Ql+J9Sotapm+CgSU8tKN0mzDnvuaGeu4zhvnN1nKPHJijPUoUjKAOf55B6/9CQ77s2TG3ybz7jBB2tiSaus+X6YXqQcvg8D0FZ/75eZw8rJ7dQQcweTnXefFXpUkcmYECuRCLsQO92xINqiTXgXjd71+P94qkiRAOmnuda1DdtEp57Jzz5qD3gkohnKCqw9hVFyqDzhNvgmDk= Content-Type: text/plain; charset="us-ascii" Content-ID: <431E5C4F4C688345ABB7F7F3714A6E90@namprd15.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 923feb45-9ecd-4b02-534c-08d6a71490cf X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Mar 2019 18:00:09.3276 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR15MB3159 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-12_10:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 12, 2019 at 12:47:12PM +1100, Tobin C. Harding wrote: > On Mon, Mar 11, 2019 at 10:48:45PM +0000, Roman Gushchin wrote: > > On Fri, Mar 08, 2019 at 03:14:15PM +1100, Tobin C. Harding wrote: > > > We have now in place a mechanism for adding callbacks to a cache in > > > order to be able to implement object migration. > > >=20 > > > Add a function __move() that implements SMO by moving all objects in = a > > > slab page using the isolate/migrate callback methods. > > >=20 > > > Co-developed-by: Christoph Lameter > > > Signed-off-by: Tobin C. Harding > > > --- > > > mm/slub.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++= ++ > > > 1 file changed, 85 insertions(+) > > >=20 > > > diff --git a/mm/slub.c b/mm/slub.c > > > index 0133168d1089..6ce866b420f1 100644 > > > --- a/mm/slub.c > > > +++ b/mm/slub.c > > > @@ -4325,6 +4325,91 @@ int __kmem_cache_create(struct kmem_cache *s, = slab_flags_t flags) > > > return err; > > > } > > > =20 > > > +/* > > > + * Allocate a slab scratch space that is sufficient to keep pointers= to > > > + * individual objects for all objects in cache and also a bitmap for= the > > > + * objects (used to mark which objects are active). > > > + */ > > > +static inline void *alloc_scratch(struct kmem_cache *s) > > > +{ > > > + unsigned int size =3D oo_objects(s->max); > > > + > > > + return kmalloc(size * sizeof(void *) + > > > + BITS_TO_LONGS(size) * sizeof(unsigned long), > > > + GFP_KERNEL); > >=20 > > I wonder how big this allocation can be? > > Given that the reason for migration is probably highly fragmented memor= y, > > we probably don't want to have a high-order allocation here. So maybe > > kvmalloc()? > >=20 > > > +} > > > + > > > +/* > > > + * __move() - Move all objects in the given slab. > > > + * @page: The slab we are working on. > > > + * @scratch: Pointer to scratch space. > > > + * @node: The target node to move objects to. > > > + * > > > + * If the target node is not the current node then the object is mov= ed > > > + * to the target node. If the target node is the current node then = this > > > + * is an effective way of defragmentation since the current slab pag= e > > > + * with its object is exempt from allocation. > > > + */ > > > +static void __move(struct page *page, void *scratch, int node) > > > +{ > >=20 > > __move() isn't a very explanatory name. kmem_cache_move() (as in Christ= opher's > > version) is much better, IMO. Or maybe move_slab_objects()? >=20 > How about move_slab_page()? We use kmem_cache_move() later in the > series. __move() moves all objects in the given page but not all > objects in this cache (which kmem_cache_move() later does). Open to > further suggestions though, naming things is hard :) >=20 > Christopher's original patch uses kmem_cache_move() for a function that > only moves objects from within partial slabs, I changed it because I did > not think this name suitably describes the behaviour. So from the > original I rename: >=20 > __move() -> __defrag() > kmem_cache_move() -> __move() > =09 > And reuse kmem_cache_move() for move _all_ objects (includes full list). >=20 > With this set applied we have the call chains >=20 > kmem_cache_shrink() # Defined in slab_common.c, exported to kernel. > -> __kmem_cache_shrink() # Defined in slub.c > -> __defrag() # Unconditionally (i.e 100%) > -> __move() >=20 > kmem_cache_defrag() # Exported to kernel > -> __defrag() > -> __move() >=20 > move_store() # sysfs > -> kmem_cache_move() > -> __move() > or > -> __move_all_objects_to() > -> kmem_cache_move() > -> __move() >=20 >=20 > Suggested improvements? move_slab_page() looks good to me. I don't have a strong opinion on naming = here, I just think that unique names are always preferred even for static functio= ns (that's why I don't like __move()). Also, it's not clear what '__' means he= re. So maybe move_slab_page(), defrag_kmem_node(), etc? Or something like this. >=20 > > Also, it's usually better to avoid adding new functions without calling= them. > > Maybe it's possible to merge this patch with (9)? >=20 > Understood. The reason behind this is that I attempted to break this > set up separating the implementation of SMO with the addition of each > feature. This function is only called when features are implemented to > use SMO, I did not want to elevate any feature above any other by > including it in this patch. I'm open to suggestions on how to order > though, also I'm happy to order it differently if/when we do PATCH > version. Is that acceptable for the RFC versions? The general rule is that any patch should be self-sufficient. If it's required to look into further patches to understand why something has been done, it makes the review process harder. I think it's possible to make the patchset to conform this rule with some almost cosmetic changes, e.g. move some changes from one patch to another, add some comments, etc. Anyway, it's definitely fine for an RFC, just something to think of in the next version. Thanks!