Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1147012rwe; Thu, 25 Aug 2022 16:56:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5m6/AchZUU+XcXPuxpVRI521sqZzcWVnKZ2H6NHKjdLseCBpHsH0xXZlU12rF5vyJ52/Kg X-Received: by 2002:a05:6402:35c:b0:43c:8f51:130 with SMTP id r28-20020a056402035c00b0043c8f510130mr4884680edw.393.1661471765010; Thu, 25 Aug 2022 16:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661471765; cv=none; d=google.com; s=arc-20160816; b=mwGq3r1IRzaAIByykN6mAKFqA5H+rd20riAvl+QsiQfxbFmlM5lcWMu8M3V8pTc8W0 HHuCXEJv+kxb/sp3QESpA04VYdpyOdhG/A5dqRqjjybS4DXS2/8yAdTFBsrUD4lajNN8 7N/c0xTnw4BGs0EibYZ7jOxZJzl2r7bpg78zwCNtc5rf7DXxTvN+ilMMU65UaiekWFaW F/KgowvDaPL6hpJAFljS6FeR9DhOnqtR29uv8OeQsdS3yvO5MRVY5YJH3UEMBlQB3tkJ YgsjxpeJGk3wSgQi4iMZ2K6uPOAjVoC9pB6UDS/WgXZr4gHcKwVEZIW/3+od1o7KPysz ATpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fZkbW2nKw9OcNR++w2Lt3hNVn3FfxAMwHGTXAs+/ztQ=; b=A88V3kQdhUyRrHHkHC9HkVA7fYNL9LHBOvanoLFLUYKU1q2IOy1zw6KP0XfCLvqFGR Wqgnh9DpUDiOi7sgJT0H/dvnn5iobZQMBnZIP+ZOK3whWfYKGZqAI+loObgj7Nzxn+9g 6lKtpparToX1ju8PA933GKWpG6q+8V7vlEKuZwCando++U5DlbxrDSwFPz5i/AEafFSd QW1+PABH9peHyXJJifbZwxArGA036vmMrI+m4euyy6jXyt50CyObPYg1gV+C67wJYKgQ xyhUG2yvpCqEfTfHr7aOZxk4zUA+ZZvr3SBKRixSZrCvgLONJBq1W8g1Ta8pDI8FSVbh kmjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NVvv0j+l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf42-20020a1709077f2a00b00730a530954dsi296553ejc.901.2022.08.25.16.55.27; Thu, 25 Aug 2022 16:56:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NVvv0j+l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244060AbiHYXg1 (ORCPT + 99 others); Thu, 25 Aug 2022 19:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231861AbiHYXgZ (ORCPT ); Thu, 25 Aug 2022 19:36:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C815ACA11 for ; Thu, 25 Aug 2022 16:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661470583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fZkbW2nKw9OcNR++w2Lt3hNVn3FfxAMwHGTXAs+/ztQ=; b=NVvv0j+l4lqJT/TDtvANtYh9/Ba/InC83JiOeGL6MfuRugbtj3E6solgKEn0iElUd9nsCN yi+iVAy1t6mnErRjOGks5hUBUCtXVu1Rs2nTVtIuTcQU9vnQG8a5gKjtwo+75WfOLKzb3B qOiH91wQpBpWWy6qk+L9oUUWfYimETE= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-650-VmH-jDZgNOiZtytVsxHhvg-1; Thu, 25 Aug 2022 19:36:22 -0400 X-MC-Unique: VmH-jDZgNOiZtytVsxHhvg-1 Received: by mail-qv1-f72.google.com with SMTP id od16-20020a0562142f1000b00496e2ea7934so8647747qvb.13 for ; Thu, 25 Aug 2022 16:36:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=fZkbW2nKw9OcNR++w2Lt3hNVn3FfxAMwHGTXAs+/ztQ=; b=VlndjqFnwv9K2tt54FJR02LdFLj60Z4xrGtAdgX+P9bcFI8sfsaBU3G6QJIb8LrQAQ UXTDBpMa7KzjoKueETJ19K/mccrI0jYnDROAviu1Wqp3DvafCNqeRUA0EFU+g4Rxon35 z3efEeakTmXqWJfnwGoNaoSLuHmBViItAUGlPtyvW9Ii4XMC2xc6PtJfmuTtrGzQimrq w7AVvytamitNKw8HUb71KkDvu8TIDNMlBj9mWNjxxOMuDN1U2H7xLrAsGz9pmf0/2UwK hfETy0l4W6DtJffsohIH49FXVunb2H0m1UiELHIeNpdXxeFMpl15DT6GNc981UdEmkeP bmcQ== X-Gm-Message-State: ACgBeo28p75YLh8ovMspLaBHuwMGmv7gVZuWgW3SOw3YtxLthss3LAXx 8OoLjKYsmD1D5ag+INF9oJsPkKLghRuWwpUP0xB0OOL5/TmXwGxdmHi3nY2Fgl5mFnxrDcOb/QU CF6j2rBXuVJpCZhwS6b44uVKu X-Received: by 2002:ac8:5948:0:b0:342:f500:2eb7 with SMTP id 8-20020ac85948000000b00342f5002eb7mr5760964qtz.483.1661470581830; Thu, 25 Aug 2022 16:36:21 -0700 (PDT) X-Received: by 2002:ac8:5948:0:b0:342:f500:2eb7 with SMTP id 8-20020ac85948000000b00342f5002eb7mr5760938qtz.483.1661470581599; Thu, 25 Aug 2022 16:36:21 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-35-70-27-3-10.dsl.bell.ca. [70.27.3.10]) by smtp.gmail.com with ESMTPSA id w16-20020a05620a425000b006bba46e5eeasm663162qko.37.2022.08.25.16.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 16:36:21 -0700 (PDT) Date: Thu, 25 Aug 2022 19:36:18 -0400 From: Peter Xu To: Alistair Popple Cc: "Huang, Ying" , Nadav Amit , huang ying , Linux MM , Andrew Morton , LKML , "Sierra Guiza, Alejandro (Alex)" , Felix Kuehling , Jason Gunthorpe , John Hubbard , David Hildenbrand , Ralph Campbell , Matthew Wilcox , Karol Herbst , Lyude Paul , Ben Skeggs , Logan Gunthorpe , paulus@ozlabs.org, linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org Subject: Re: [PATCH v2 1/2] mm/migrate_device.c: Copy pte dirty bit to page Message-ID: References: <87czcyawl6.fsf@yhuang6-desk2.ccr.corp.intel.com> <874jy9aqts.fsf@yhuang6-desk2.ccr.corp.intel.com> <87czcqiecd.fsf@nvdebian.thelocal> <87o7w9f7dp.fsf@nvdebian.thelocal> <87k06xf70l.fsf@nvdebian.thelocal> <877d2wezll.fsf@nvdebian.thelocal> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <877d2wezll.fsf@nvdebian.thelocal> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 26, 2022 at 08:09:28AM +1000, Alistair Popple wrote: > > I looked at some of the callers, it seems not all of them are ready to > > handle that (__kvmppc_svm_page_out() or svm_migrate_vma_to_vram()). Is it > > safe? Do the callers need to always properly handle that (unless the > > migration is only a best-effort, but it seems not always the case). > > Migration is always best effort. Callers need to be prepared to handle > failure of a particular page to migrate, but I could believe not all of > them are. Ok, I see that ppc list is in the loop, hopefully this issue is aware since afaict ppc will sigbus when migrate_vma_setup() fails, otoh the svm code just dumps some device error (and I didn't check upper the stack from there). > > > Besides, since I read the old code of prepare(), I saw this comment: > > > > - if (!(migrate->src[i] & MIGRATE_PFN_LOCKED)) { > > - /* > > - * Because we are migrating several pages there can be > > - * a deadlock between 2 concurrent migration where each > > - * are waiting on each other page lock. > > - * > > - * Make migrate_vma() a best effort thing and backoff > > - * for any page we can not lock right away. > > - */ > > - if (!trylock_page(page)) { > > - migrate->src[i] = 0; > > - migrate->cpages--; > > - put_page(page); > > - continue; > > - } > > - remap = false; > > - migrate->src[i] |= MIGRATE_PFN_LOCKED; > > - } > > > > I'm a bit curious whether that deadlock mentioned in the comment is > > observed in reality? > > > > If the page was scanned in the same address space, logically the lock order > > should be guaranteed (if both page A&B, both threads should lock in order). > > I think the order can be changed if explicitly did so (e.g. fork() plus > > mremap() for anonymous here) but I just want to make sure I get the whole > > point of it. > > You seem to have the point of it. The trylock_page() is to avoid > deadlock, and failure is always an option for migration. Drivers can > always retry if they really need the page to migrate, although success > is never guaranteed. For example the page might be pinned (or have > swap-cache allocated to it, but I'm hoping to at least get that fixed). If so I'd suggest even more straightforward document for either this trylock() or on the APIs (e.g. for migrate_vma_setup()). This behavior is IMHO hiding deep and many people may not realize. I'll comment in the comment update patch. Thanks. -- Peter Xu