Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4901371imm; Tue, 16 Oct 2018 01:44:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV63MkNwoFKt9HoRFnNsRz6JWU21fTdW2XjF1KVsUtNED/F7HvJAwL0C3uaCNAGqOT5HZe4eL X-Received: by 2002:a17:902:b90c:: with SMTP id bf12-v6mr20793948plb.259.1539679473670; Tue, 16 Oct 2018 01:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539679473; cv=none; d=google.com; s=arc-20160816; b=LOLlsmzEVr8fP5JVkNXUB+EsQgTBZRH5t5C6Jt/rHm9XTXxRW3CZm/3AK1PxAJKFTo 8qcJ78YD0XKp/qtESWzoKKitv+8EflIl/RGTt8YjN87wjepIFbxrbs0RhZq467qqo1Ll OCXVKVt9WflN3BXH8e1eIz24vO6X1UYwHSUR9ztA3NzjM/6KhCYmlBcZFd+zpDwqjr+k Hgaa3I8FpVEYSOs42wWF8dlaLaepsxyZGrAENYmQ8umGmjDJ2j6HadnjRTIjEpBCw8K8 HLw1vi9V35I6LwNXT+L0FJgWHyhzJ1d0umZrMfXHU4dyOjDZoX9Zwo+33K0XkLIgTp13 /0DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:mime-version:date:references :in-reply-to:subject:cc:to:from; bh=NHoAp9VDrNfN53sfq38Ue9NpBP6N3t5/LJP0376v03Q=; b=IDN8VCYb+4rOT4hN5knuKy7EZ8M61V7as0YacgrK3vftq+ApFLtWTLHjCyUnoh5f5N SqU0UegMEPB/kH2/dxkpXfCWOEepTdqmlpdbcXr5JIAiEnLSRPgdt/76eisSdBj/558h ctnkm7kWuNCX5EpLVjyfKze+uAO6EbwIubiICsdBtLPKKlE+tPAiNOEhDKOCiSsTBG6F RRCYiF5TsLz7bNgc7wnDZVn+W5yTEJUYYYtuBgauT00LPgixKnyE/wN96w+kTQR0TQaw ngptbol3r3cYS4abEPVlw6Gxxs3mVFnKWCC31PVhKidbRvYly0ZkgojSJ96wG0oE7PIA RhVw== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p71-v6si13392831pfk.275.2018.10.16.01.42.39; Tue, 16 Oct 2018 01:44:33 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbeJPQYz (ORCPT + 99 others); Tue, 16 Oct 2018 12:24:55 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58680 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726453AbeJPQYz (ORCPT ); Tue, 16 Oct 2018 12:24:55 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9G8YmBc109113 for ; Tue, 16 Oct 2018 04:35:36 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n57pwtqqx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 16 Oct 2018 04:35:35 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Oct 2018 09:35:33 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 16 Oct 2018 09:35:28 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9G8ZSkE4391236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 16 Oct 2018 08:35:28 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8E17A404D; Tue, 16 Oct 2018 11:34:57 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2204AA4057; Tue, 16 Oct 2018 11:34:56 +0100 (BST) Received: from skywalker (unknown [9.199.58.69]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Tue, 16 Oct 2018 11:34:55 +0100 (BST) Received: (nullmailer pid 25992 invoked by uid 1000); Tue, 16 Oct 2018 08:35:25 -0000 From: "Aneesh Kumar K.V" To: Alexey Kardashevskiy , akpm@linux-foundation.org, Michal Hocko , mpe@ellerman.id.au Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH V3 1/2] mm: Add get_user_pages_cma_migrate In-Reply-To: <485adcad-4996-ae2c-c098-9dc7bcd2d29a@ozlabs.ru> References: <20180918115839.22154-1-aneesh.kumar@linux.ibm.com> <20180918115839.22154-2-aneesh.kumar@linux.ibm.com> <6112386d-65cd-fc1f-b012-e33da2c3b8fe@ozlabs.ru> <87murewecs.fsf@linux.ibm.com> <485adcad-4996-ae2c-c098-9dc7bcd2d29a@ozlabs.ru> Date: Tue, 16 Oct 2018 14:05:25 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 18101608-0012-0000-0000-000002B79DEA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101608-0013-0000-0000-000020EC1312 Message-Id: <87in22wape.fsf@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-16_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=44 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=824 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810160076 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Alexey Kardashevskiy writes: > On 16/10/2018 18:16, Aneesh Kumar K.V wrote: >> Alexey Kardashevskiy writes: >> >>> + } >>>> + } >>>> + } >>>> + if (!list_empty(&cma_page_list)) { >>>> + /* >>>> + * drop the above get_user_pages reference. >>>> + */ > > > btw, can these pages be used by somebody else in this short window > before we migrated and pinned them? isolate lru page make sure that we remove them from lru list. So lru walkers won't find the page. If somebody happen to increment the page reference count in that window, the migrate_pages will fail. That is handled via migrate_page_move_mapping returning EAGAIN > > >>>> + for (i = 0; i < ret; ++i) >>>> + put_page(pages[i]); >>>> + >>>> + if (migrate_pages(&cma_page_list, new_non_cma_page, >>>> + NULL, 0, MIGRATE_SYNC, MR_CONTIG_RANGE)) { >>>> + /* >>>> + * some of the pages failed migration. Do get_user_pages >>>> + * without migration. >>>> + */ >>>> + migrate_allow = false; >>> >>> >>> migrate_allow seems useless, simply calling get_user_pages_fast() should >>> make the code easier to read imho. And the comment says >>> get_user_pages(), where does this guy hide? >> >> I didn't get that suggestion. What we want to do here is try to migrate pages as >> long as we find CMA pages in the result of get_user_pages_fast. If we >> failed any migration attempt, don't try to migrate again. > > > Setting migrate_allow to false here means you jump up, call > get_user_pages_fast() and then run the loop which will do nothing just > because if(...migrate_allow) is false. Instead of jumping up you could > just call get_user_pages_fast(). ok, that is coding preference I guess, I prefer to avoid multiple get_user_pages_fast there. Since we droped the page reference, we need to _go back_ and get the page reference without attempting to migrate. That is the way I was looking at this. > > btw what is migrate_pages() leaves something in cma_page_list (I cannot > see it removing pages)? Won't it loop indefinitely? > putback_movable_pages take care of that. The below hunk. if (!list_empty(&cma_page_list)) putback_movable_pages(&cma_page_list); -aneesh