Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4530216pxf; Tue, 30 Mar 2021 09:57:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1OUcjMebWK28hbV1X/htwVb89GYlNbS8lq+a+QlWBa6GqfCVDoNqg1tJ5FnMleUh2PkTe X-Received: by 2002:a17:907:5090:: with SMTP id fv16mr19797209ejc.90.1617123421676; Tue, 30 Mar 2021 09:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617123421; cv=none; d=google.com; s=arc-20160816; b=0H+V5JQaUSTswsxvVgiaMu8bJdtq6IsOqqt0XbxnBW1QXTTeRF+bMKIhNpjKoYPmzN bF4Y5sS+jT5kK/YlilXndYIN7QQ0BQNLfN036H4H/a7BRL3K12+eKDmRLrKZDDHIaWax +D0zDESQzBP3wVwLp5EE+wpq5Ky7epjJGSjHdpmVVMP5GCJOybsIxsEgUT/RIKg7yF9X aGIKdee/jKE/UkwVQVRnfNn2JTZx+EovnixJ89JWNAF/EpPm1aFNYg6Vjid6k5BUNjTv GT1MW9UCe7S0RZoDdnqZdrOPD/RRjt39gWIRihAg4AAuoE+oJ/QvrlFCU6D9ANa1PoKB /HvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rHYeB0nnI6v6P0Q2VG5Mm28e6mrALqMkMyegkWOwiqk=; b=o2Qo83Pv3GPaE75fo5GrDkc0qLkyrRf2/lmZQbK51XLvXHF764wpQfewfOfhZwr6Z8 OT8cb5aij0i9nYTcP0UCPnndsRM0ivyJkt1YstcWd6F6NWGzeQwBrga6WFrIyLako6Br crYv1Mekr0Ut24B5YqcfMw7KidphOzJr6KxrkMIq4W3xFMChBxfvCMMgBpdE1/vxhKtr HYdAysTGl0+wl2E0J2WaaSs1n+fsFf8iJ/ppCx99c9ojQYGq0zXPTFNvGv2ddGjnveGq IbSVqYPOHN1PRAFj/wdqZrGhNWkb+znSh72foGyTF+VOfggJBxc9LqAPHDD7cp1EYeoZ R7HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kGJmMRBz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si14448998edd.128.2021.03.30.09.56.39; Tue, 30 Mar 2021 09:57:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kGJmMRBz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232367AbhC3QwR (ORCPT + 99 others); Tue, 30 Mar 2021 12:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbhC3QwA (ORCPT ); Tue, 30 Mar 2021 12:52:00 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C074CC061574; Tue, 30 Mar 2021 09:51:59 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id l4so25838956ejc.10; Tue, 30 Mar 2021 09:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rHYeB0nnI6v6P0Q2VG5Mm28e6mrALqMkMyegkWOwiqk=; b=kGJmMRBzcADUj4PBwV6ce2pTpWYreP0vdr0R/+o6Mk3bwh3JjUTnV1mwN+aBTDqACg NjqoAQn6WyqUIAcWIbtJLQoPA4jxG/baST+8P6IplHfk3UNcnTEVamzs5uJNK+rWLAIj 04bNS9hxYXVaZQ1rOCdTC4OVWa5ZEAMYgy0yE2srmI9/GhDYtS8utBzwLA5oE3l0UGBy Tu3ZDVizHWEgfsETi/mPfPDV93rpLDs8OjBQUi0sN2fsGAUOEQrtazjCY+ohgxPH42rI 2phdDmXtg81Akx9vv30xSdksoKpssSAyukxRlsNP5kV7ydTZwyQQKADSefZgI+Kzumrx UfRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rHYeB0nnI6v6P0Q2VG5Mm28e6mrALqMkMyegkWOwiqk=; b=US5DBgEZQCCqFX61Dz4R0dFPmONMsMfZjAN7vmVx2yAdzLW44kAaJYSJJon13HkuUK 4kKwPenP2NbPZZsXhLl5gbcAMCUigxG6V0hVbWw3iPhiT9liVMd+7LYj6O/hFTi09Xj8 qexiaZjgavh+CDwf3Q9OA9rZl+LLegvca8cdRJDj3nJuCy6rlK3CYfHw7KvIzQNBV/2v W/vo+50ids5cIL7Fl9JxjCVzWWTcAbs6N+HT6HFUIdBCR7XmiDo9u6SP+0taAaZvQD4B qyrcap8fDN/XjyyjESKVmd+jyt7BFU2bwEcPTWSCFtmzoqAYkiFz5sZXt26vRm9Y+OUY poIQ== X-Gm-Message-State: AOAM531bk0rmB0KO5A6XcI8ZZQx5B1ojPxmL0jXB2qI83Me6YtYMEMpF TuciHEkGgIqJK4WllJqgmnYJldcLKOifFbjAWhQ= X-Received: by 2002:a17:906:4055:: with SMTP id y21mr33697021ejj.507.1617123118539; Tue, 30 Mar 2021 09:51:58 -0700 (PDT) MIME-Version: 1.0 References: <20210329183312.178266-1-shy828301@gmail.com> <20210330164200.01a4b78f@thinkpad> In-Reply-To: <20210330164200.01a4b78f@thinkpad> From: Yang Shi Date: Tue, 30 Mar 2021 09:51:46 -0700 Message-ID: Subject: Re: [RFC PATCH 0/6] mm: thp: use generic THP migration for NUMA hinting fault To: Gerald Schaefer Cc: Mel Gorman , "Kirill A. Shutemov" , Zi Yan , Michal Hocko , Huang Ying , Hugh Dickins , hca@linux.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com, Andrew Morton , Linux MM , linux-s390@vger.kernel.org, Linux Kernel Mailing List , Alexander Gordeev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 30, 2021 at 7:42 AM Gerald Schaefer wrote: > > On Mon, 29 Mar 2021 11:33:06 -0700 > Yang Shi wrote: > > > > > When the THP NUMA fault support was added THP migration was not supported yet. > > So the ad hoc THP migration was implemented in NUMA fault handling. Since v4.14 > > THP migration has been supported so it doesn't make too much sense to still keep > > another THP migration implementation rather than using the generic migration > > code. It is definitely a maintenance burden to keep two THP migration > > implementation for different code paths and it is more error prone. Using the > > generic THP migration implementation allows us remove the duplicate code and > > some hacks needed by the old ad hoc implementation. > > > > A quick grep shows x86_64, PowerPC (book3s), ARM64 ans S390 support both THP > > and NUMA balancing. The most of them support THP migration except for S390. > > Zi Yan tried to add THP migration support for S390 before but it was not > > accepted due to the design of S390 PMD. For the discussion, please see: > > https://lkml.org/lkml/2018/4/27/953. > > > > I'm not expert on S390 so not sure if it is feasible to support THP migration > > for S390 or not. If it is not feasible then the patchset may make THP NUMA > > balancing not be functional on S390. Not sure if this is a show stopper although > > the patchset does simplify the code a lot. Anyway it seems worth posting the > > series to the mailing list to get some feedback. > > The reason why THP migration cannot work on s390 is because the migration > code will establish swap ptes in a pmd. The pmd layout is very different from > the pte layout on s390, so you cannot simply write a swap pte into a pmd. > There are no separate swp primitives for swap/migration pmds, IIRC. And even > if there were, we'd still need to find some space for a present bit in the > s390 pmd, and/or possibly move around some other bits. > > A lot of things can go wrong here, even if it could be possible in theory, > by introducing separate swp primitives in common code for pmd entries, along > with separate offset, type, shift, etc. I don't see that happening in the > near future. Thanks a lot for elaboration. IIUC, implementing migration PMD entry is *not* prevented from by hardware, it may be very tricky to implement it, right? > > Not sure if this is a show stopper, but I am not familiar enough with > NUMA and migration code to judge. E.g., I do not see any swp entry action > in your patches, but I assume this is implicitly triggered by the switch > to generic THP migration code. Yes, exactly. The migrate_pages() called by migrate_misplaced_page() takes care of everything. > > Could there be a work-around by splitting THP pages instead of marking them > as migrate pmds (via pte swap entries), at least when THP migration is not > supported? I guess it could also be acceptable if THP pages were simply not > migrated for NUMA balancing on s390, but then we might need some extra config > option to make that behavior explicit. Yes, it could be. The old behavior of migration was to return -ENOMEM if THP migration is not supported then split THP. That behavior was not very friendly to some usecases, for example, memory policy and migration lieu of reclaim (the upcoming). But I don't mean we restore the old behavior. We could split THP if it returns -ENOSYS and the page is THP. > > See also my comment on patch #5 of this series. > > Regards, > Gerald