Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp287139imu; Thu, 20 Dec 2018 22:25:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN442fq0AePmTumtTXMBHwD9BonSP0GocrxeLB2NIrTvAU7+veQ5f6bbCdB9IvergFyQhfce X-Received: by 2002:a17:902:9006:: with SMTP id a6mr1257521plp.334.1545373519621; Thu, 20 Dec 2018 22:25:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545373519; cv=none; d=google.com; s=arc-20160816; b=AK5RCxANlkbUtMXLi5YeJ5wrbtdSIMu+1wcBBwESFjwHKDEavjm49LpoG+SVbyTvNe e3Cd75hAS97wnqmOKGgw4v5XbQw8S2ew61MhAAnyXZrle2FPD2bIKlaXhv7uVdVLf/ng AL4pjNMKH4iSg0gQusFyon0gExXNszO/TmBqk7kujpGFucDfU09fH+MBFQcCj39Ervt4 +Rmha6aUdY2Uq6dZPFBco5RIzFK8l4RrHeJfHGsWcM1W/DQjhGrk78zvpqjZ3Ty68fWN Bw3gACS1LOdIVHicjj4UoWqAlAKn6t92Pf5+ExZQRLbu4/R2BitLkmzb2fM08iNOA7hf gpEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:content-disposition :mime-version:references:subject:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:to :from:date:user-agent:message-id:dkim-signature; bh=w1fmM/A7/dLGujgt4qj/eIcE2IM8trq03+WjkP6rwKM=; b=YsCbkOKwkOGt8wPxQ9trblaUa+TmsESHjYs09Pvmkmv7jJpBfY0yz0+6tEMBW/bU+Q 1HMC3iic56Xzo/fQ3ECKWftObKf2pQBCSVliqKGdVPa3j08c7HdI6nklx576O9CQHTs9 th7TnlNhdx0diI4GFQylhyNWONX8KoM6FnnAfaKp0tDZQi/jrOYmZScnHeQQFSl7B782 1ZclJSqcXtqYe281Xsp8ZDtpWPlZJgiTv2QIfxMwAMUtm4hiJiLYIn8M8Twk89flyAFR b+o84r1OYdvqPJYV9k9nNr56TmyD1l2zGeKoK20axpR1tA2g2OHOoBvWX1M7oXP2tsqZ Yn1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=SCvVL+ju; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i62si8365983pfc.17.2018.12.20.22.25.02; Thu, 20 Dec 2018 22:25:19 -0800 (PST) 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=fail header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=SCvVL+ju; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389445AbeLTTWS (ORCPT + 99 others); Thu, 20 Dec 2018 14:22:18 -0500 Received: from a9-99.smtp-out.amazonses.com ([54.240.9.99]:43178 "EHLO a9-99.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389400AbeLTTWF (ORCPT ); Thu, 20 Dec 2018 14:22:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1545333723; h=Message-Id:Date:From:To:Cc:Cc:Cc:CC:Cc:Cc:Cc:Cc:Cc:Cc:Cc:Subject:References:MIME-Version:Content-Type:Feedback-ID; bh=qNdEXLooQmyJC8nAB/4MyBKqNpzM7jv1JHGkgte2EEs=; b=SCvVL+juPo8Ksu9+O0sk/r8AiUR8JGnyzXhP7mYdvc3cEQ0ulPEhnt+VLcPLe1mc smDDyDaYkQ6dcwgZE1Tk0m8tUHdSf90cH0en+w2zBJBvdu+bFjmIMne/tJlZiqGphRG 85bQcTIpVPEKivVme9DnvBzP1GZjcA05QzDioYdE= Message-ID: <01000167cd11517f-f122b002-1a61-46c9-af1a-5c7cf01a397d-000000@email.amazonses.com> User-Agent: quilt/0.65 Date: Thu, 20 Dec 2018 19:22:03 +0000 From: Christoph Lameter To: Matthew Wilcox Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Cc: Pekka Enberg CC: akpm@linux-foundation.org Cc: Mel Gorman Cc: andi@firstfloor.org Cc: Rik van Riel Cc: Dave Chinner Cc: Christoph Hellwig Cc: Michal Hocko Cc: Mike Kravetz Subject: [RFC 7/7] xarray: Implement migration function for objects References: <20181220192145.023162076@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=xarray X-SES-Outgoing: 2018.12.20-54.240.9.99 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement functions to migrate objects. This is based on initial code by Matthew Wilcox and was modified to work with slab object migration. Signed-off-by: Christoph Lameter Index: linux/lib/radix-tree.c =================================================================== --- linux.orig/lib/radix-tree.c +++ linux/lib/radix-tree.c @@ -1613,6 +1613,18 @@ static int radix_tree_cpu_dead(unsigned return 0; } + +extern void xa_object_migrate(void *tree_node, int numa_node); + +static void radix_tree_migrate(struct kmem_cache *s, void **objects, int nr, + int node, void *private) +{ + int i; + + for (i=0; iarray); + void __rcu **slot; + struct xa_node *new_node; + int i; + + /* Freed or not yet in tree then skip */ + if (!xa || xa == XA_FREE_MARK) + return; + + new_node = kmem_cache_alloc_node(radix_tree_node_cachep, GFP_KERNEL, numa_node); + + xa_lock_irq(xa); + + /* Check again..... */ + if (xa != node->array || !list_empty(&node->private_list)) { + node = new_node; + goto unlock; + } + + memcpy(new_node, node, sizeof(struct xa_node)); + + /* Move pointers to new node */ + INIT_LIST_HEAD(&new_node->private_list); + for (i = 0; i < XA_CHUNK_SIZE; i++) { + void *x = xa_entry_locked(xa, new_node, i); + + if (xa_is_node(x)) + rcu_assign_pointer(xa_to_node(x)->parent, new_node); + } + if (!new_node->parent) + slot = &xa->xa_head; + else + slot = &xa_parent_locked(xa, new_node)->slots[new_node->offset]; + rcu_assign_pointer(*slot, xa_mk_node(new_node)); + +unlock: + xa_unlock_irq(xa); + xa_node_free(node); + rcu_barrier(); + return; + +} + #ifdef XA_DEBUG void xa_dump_node(const struct xa_node *node) {