Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6790192ybi; Wed, 5 Jun 2019 06:29:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJBDF1YrVIhWscTxsXiSPvcbphg73SwTiPQkoBs64nW+dVCz2rLQmSrSQCl0tFphuGq3cx X-Received: by 2002:a17:902:b691:: with SMTP id c17mr21237740pls.107.1559741341229; Wed, 05 Jun 2019 06:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559741341; cv=none; d=google.com; s=arc-20160816; b=k+ReFauuKWWdw9ustSoHdG7DFpamqnirN+gcO2eLO4SCazz8rxbln5cl7sxuqKOkIh veFw7rxVvC04yvuzXLYiOhLUe9sFAV9455kGbw7y2xVgpTr2PTq6E5pm3XEmX0ICkbue raIaa0FAl7EtmqTRC1QDUr7xqDmARjfmksnFIfvtWqoCHdX05l1WqavYy4+XqcX3YWrS KKBwAFyhdRhY3e36AP+Ihu544S4P0UuycD/yfypW0qI95IFR+6HgiA3MXHXYgzN/5/YV tfckjaw4E6GiJ7zf9gShWxPtlWk6ThqFkjNSL+Rel70EXehVHioa6IuwMx3IHp+IhWUl piSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8UF6IKh1oi+AJKntkp2Avzsj99+2nJ602b//xWwwYMo=; b=jNUEguvAzTUt5ba/n6sU2RTRo4BOe8DXXssJ+Ln1BTcfTAVAu5T10XWx6lR8PBoIr2 U1E7NvN2U3QZ9nIJazwjbq6xoHmck6iumGhfy29dMUO1Oh05+TmWKHm3qnlOrG9eiIjU VO52GBr3TNOi1Cvqnh4hqGjzOTpd/0Zp2gIfJOe3AvU2DAxoI65RxMJwCeZJCWqZtI2i Rny1s0aTEZuFAqBWHz3dywFg1pKPzuhHFJ+7lVUggar/AzqRrFL6s7C+om4Vl4+wqSBI fP4F/5sfkqVmmcyXlv7rDBjkJbr8rVFzDGO9sF0ZUV6TlMCme38AVzfSqoZp61payRob AI9A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u126si23680444pgu.117.2019.06.05.06.28.43; Wed, 05 Jun 2019 06:29:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727970AbfFEN1d (ORCPT + 99 others); Wed, 5 Jun 2019 09:27:33 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:36378 "EHLO mail-wr1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbfFEN1c (ORCPT ); Wed, 5 Jun 2019 09:27:32 -0400 Received: by mail-wr1-f42.google.com with SMTP id n4so16432535wrs.3 for ; Wed, 05 Jun 2019 06:27:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8UF6IKh1oi+AJKntkp2Avzsj99+2nJ602b//xWwwYMo=; b=QHTmMCwRqtNXgLDmHNKcy+wofeiiuWQHl484tB5mimcpMieslspQ2JuGNzD0dkgE9c 0kWEbceOWwP5PemJiGZwObFFjv+hV8GbJyz21piGd8OWokZc2CVV7vDQh79Fbn9XepnJ Pp2UDIlOqwzfn8oxqHMNIetuY/evyHV4CcN0bG2LJhAOkFjiITSVhxywwW5EEcdrKdYS FbFIApCMtze8K8bFyBG8/uFVeU8OsDMVaYYGbbpCNdMkjo3Ojsz85qnqUkK4fqB/23NJ aNqvBI3yTmkUN3b/7aU7H4xHNocNqrDjzypD699+YOqxGsmIYfAD/r9NH6a7HSUyzMW6 fjiA== X-Gm-Message-State: APjAAAXpESttmlwaZOvgbuDFi0hgMMBW7eusXwoR5xEhZZhRqbot8g2/ E57/G9ljYOzwBcEkcSMJ07lSrw== X-Received: by 2002:adf:e4d2:: with SMTP id v18mr10605225wrm.189.1559741250343; Wed, 05 Jun 2019 06:27:30 -0700 (PDT) Received: from localhost (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id u205sm24193031wmu.47.2019.06.05.06.27.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 05 Jun 2019 06:27:29 -0700 (PDT) Date: Wed, 5 Jun 2019 15:27:28 +0200 From: Oleksandr Natalenko To: Minchan Kim Cc: Andrew Morton , linux-mm , LKML , linux-api@vger.kernel.org, Michal Hocko , Johannes Weiner , Tim Murray , Joel Fernandes , Suren Baghdasaryan , Daniel Colascione , Shakeel Butt , Sonny Rao , Brian Geffon , jannh@google.com, oleg@redhat.com, christian@brauner.io, hdanton@sina.com Subject: Re: [RFCv2 4/6] mm: factor out madvise's core functionality Message-ID: <20190605132728.mihzzw7galqjf5uz@butterfly.localdomain> References: <20190531064313.193437-1-minchan@kernel.org> <20190531064313.193437-5-minchan@kernel.org> <20190531070420.m7sxybbzzayig44o@butterfly.localdomain> <20190531131226.GA195463@google.com> <20190531143545.jwmgzaigd4rbw2wy@butterfly.localdomain> <20190531232959.GC248371@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531232959.GC248371@google.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi. On Sat, Jun 01, 2019 at 08:29:59AM +0900, Minchan Kim wrote: > > > > > /* snip a lot */ > > > > > > > > > > #ifdef CONFIG_MEMORY_FAILURE > > > > > if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE) > > > > > - return madvise_inject_error(behavior, start, start + len_in); > > > > > + return madvise_inject_error(behavior, > > > > > + start, start + len_in); > > > > > > > > Not sure what this change is about except changing the line length. > > > > Note, madvise_inject_error() still operates on "current" through > > > > get_user_pages_fast() and gup_pgd_range(), but that was not changed > > > > here. I Know you've filtered out this hint later, so technically this > > > > is not an issue, but, maybe, this needs some attention too since we've > > > > already spotted it? > > > > > > It is leftover I had done. I actually modified it to handle remote > > > task but changed my mind not to fix it because process_madvise > > > will not support it at this moment. I'm not sure it's a good idea > > > to change it for *might-be-done-in-future* at this moment even though > > > we have spotted. > > > > I'd expect to have at least some comments in code on why other hints > > are disabled, so if we already know some shortcomings, this information > > would not be lost. > > Okay, I will add some comment but do not want to fix code piece until > someone want to expose the poisoning to external process. Fair enough. > > > > > write = madvise_need_mmap_write(behavior); > > > > > if (write) { > > > > > - if (down_write_killable(¤t->mm->mmap_sem)) > > > > > + if (down_write_killable(&mm->mmap_sem)) > > > > > return -EINTR; > > > > > > > > Do you still need that trick with mmget_still_valid() here? > > > > Something like: > > > > > > Since MADV_COLD|PAGEOUT doesn't change address space layout or > > > vma->vm_flags, technically, we don't need it if I understand > > > correctly. Right? > > > > I'd expect so, yes. But. > > > > Since we want this interface to be universal and to be able to cover > > various needs, and since my initial intention with working in this > > direction involved KSM, I'd ask you to enable KSM hints too, and once > > (and if) that happens, the work there is done under write lock, and > > you'll need this trick to be applied. > > > > Of course, I can do that myself later in a subsequent patch series once > > (and, again, if) your series is merged, but, maybe, we can cover this > > already especially given the fact that KSM hinting is a relatively easy > > task in this pile. I did some preliminary tests with it, and so far no > > dragons have started to roar. > > Then, do you mind sending a patch based upon this series to expose > MADV_MERGEABLE to process_madvise? It will have the right description > why you want to have such feature which I couldn't provide since I don't > have enough material to write the motivation. And the patch also could > include the logic to prevent coredump race, which is more proper since > finally we need to hold mmap_sem write-side lock, finally. > I will pick it up and will rebase since then. Sure, I can. Would you really like to have it being based on this exact revision, or I should wait till you deal with MADV_COLD & Co and re-iterate this part again? Thanks. -- Best regards, Oleksandr Natalenko (post-factum) Senior Software Maintenance Engineer