Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5222754pxu; Tue, 22 Dec 2020 11:16:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwt2fmQx9txiP59Aiv0U+hKq3qbEZ/FDCllcGY8izqu2emZKNF6nQkfbXdYIr4GlYxondk/ X-Received: by 2002:a17:907:1004:: with SMTP id ox4mr20769859ejb.240.1608664611580; Tue, 22 Dec 2020 11:16:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608664611; cv=none; d=google.com; s=arc-20160816; b=ikGT3FFGws/zV8+LAF89pf/g8KEIRKAtdPoKFXndThoId7N8TccEgUl9+adc0m/8/d hJOVMEX0RT7siR1OlFTdL+53WEsQHpv607qQ9bcNJJWgNEB0+UuANEATtPf1U+tkjU36 LmsGLGiB03K9CEiEj7spNwxP2EDQMBWmBMqaiuj7iPGlB9KYoPTn93M0aDuRFB5trKIf 6nn+m+swM+lYsCzingmJmOhJzc3nrTo488xw9mAh2FbMKKbvYzHHOFtIsvOHQLS/zdLv eQjjcK9BhW1KzNOW6WlzaeWL8zurpgF+/GooG/IYXTAelPnE+aZXRTROoApMlOh7weYn NQ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QJAkIaRAmbTjT49QW8oYv7QzM88P6GE6t4wSLLc/GcU=; b=zGm2B3liPZeBW4FpB7T/vhKPS97JPOhi5o0irhY9igTLZ6oXK+wooT0ISTM4M9kvNB GWIX4YgI+c3haeNQZnhOAz7Q+S+kXsIaI0Wa2j/WaELlmIKKmW5xyEb68X7B08EVc5Tl l4qwRGQ3DFMWMnnG0tatTIiMEi2jfEagAEGSlX1CUsd0iqlVmuN13BJBActv3SvLwutr mndUllzXjN1Tz12a/jtJ9IOOseeNEyBz1sxsa4Eq1VxZctFK8pAAYWi6IYoFzMeNwe+O q8YmEWvdvV+gA/gFzEw+XKWWYCu98Sbn7pVDNb4dyiAdjXoMlWfstX+mNr3PrucjZTsI WAzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="aPF/YAZ9"; 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 jg30si10146297ejc.353.2020.12.22.11.16.27; Tue, 22 Dec 2020 11:16:51 -0800 (PST) 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="aPF/YAZ9"; 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 S1726734AbgLVTOi (ORCPT + 99 others); Tue, 22 Dec 2020 14:14:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgLVTOi (ORCPT ); Tue, 22 Dec 2020 14:14:38 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA866C0613D3 for ; Tue, 22 Dec 2020 11:13:57 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id y5so12953610iow.5 for ; Tue, 22 Dec 2020 11:13:57 -0800 (PST) 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; bh=QJAkIaRAmbTjT49QW8oYv7QzM88P6GE6t4wSLLc/GcU=; b=aPF/YAZ9erWveRdWO/2hLJheEsEUVZm7epizh5j/VC7kd5b1Or/+tJGPitWc8dSQJP GYAtfRS/iPRCqfuJh9isOkZeiQaHR/W9ZPkmeyYncwIgToIvh4y8xmVs/5oK/tqpHpwj DICtixudSLvfYeRUBOCe0XmxF9mvT+NZwpUa5M36qLPwiW0Jlpze8AF/V0Ql5w9Q8O3W iOShXZkUa915bP42rj1Dmmjh3R4RqVNe7xyqCdswjsY1+7z8cdkhDh0KBMYV/9fVQFm8 +CutoBZSQk7bBC50n1TqdRbxekHfa/PPIO3Fh2PHqlr9OAzu5NuuAc/fmBau3hVgVHb7 SWcg== 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; bh=QJAkIaRAmbTjT49QW8oYv7QzM88P6GE6t4wSLLc/GcU=; b=g9rJBVOn5F5OCJZeudmsqpVCV1NxQYiYT3wG1MXJf840LWj5KwvQjgxaQ1CD2Uykd8 C+3j74+zMpHPKd2fo4SYWgYxMbSXULufdaArN11xJVzdHnI2J3jejukP0G5x0x3P+rC+ 5hpevuJZ8nylIMoM/K8STzYb6NQdEOw7DoEM+w2fTIvDQBJxQdGIae/hLD5y2Gc5Z3ft AJhU2tbxO/cPGB6E/VsPaVJQb/Vut8ej0KutcUX8NocGzuit15Yz+jYRB7K0jBAXG/G5 fFkk0cGjfb/HJORm4gd1QRVU0jTChaq8cIl2O7Shkg1ZLB7ZMmuAftJT1lPLQDHultC4 UUlQ== X-Gm-Message-State: AOAM533ysuy4+1s6qDvDVNiv+zzym5gfpz4N0/pP3Zz5YNqmJOERsJRR +nZR5tWipjYaJp3OOAztkiK4iUYI1aF3xfJrCyE= X-Received: by 2002:a05:6602:150b:: with SMTP id g11mr18941096iow.88.1608664437267; Tue, 22 Dec 2020 11:13:57 -0800 (PST) MIME-Version: 1.0 References: <20201221162519.GA22504@open-light-1.localdomain> In-Reply-To: <20201221162519.GA22504@open-light-1.localdomain> From: Alexander Duyck Date: Tue, 22 Dec 2020 11:13:46 -0800 Message-ID: Subject: Re: [RFC v2 PATCH 0/4] speed up page allocation for __GFP_ZERO To: Alexander Duyck , Mel Gorman , Andrew Morton , Andrea Arcangeli , Dan Williams , "Michael S. Tsirkin" , David Hildenbrand , Jason Wang , Dave Hansen , Michal Hocko , Liang Li , linux-mm , LKML , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 21, 2020 at 8:25 AM Liang Li wrote: > > The first version can be found at: https://lkml.org/lkml/2020/4/12/42 > > Zero out the page content usually happens when allocating pages with > the flag of __GFP_ZERO, this is a time consuming operation, it makes > the population of a large vma area very slowly. This patch introduce > a new feature for zero out pages before page allocation, it can help > to speed up page allocation with __GFP_ZERO. > > My original intention for adding this feature is to shorten VM > creation time when SR-IOV devicde is attached, it works good and the > VM creation time is reduced by about 90%. > > Creating a VM [64G RAM, 32 CPUs] with GPU passthrough > ===================================================== > QEMU use 4K pages, THP is off > round1 round2 round3 > w/o this patch: 23.5s 24.7s 24.6s > w/ this patch: 10.2s 10.3s 11.2s > > QEMU use 4K pages, THP is on > round1 round2 round3 > w/o this patch: 17.9s 14.8s 14.9s > w/ this patch: 1.9s 1.8s 1.9s > ===================================================== > > Obviously, it can do more than this. We can benefit from this feature > in the flowing case: So I am not sure page reporting is the best thing to base this page zeroing setup on. The idea with page reporting is to essentially act as a leaky bucket and allow the guest to drop memory it isn't using slowly so if it needs to reinflate it won't clash with the applications that need memory. What you are doing here seems far more aggressive in that you are going down to low order pages and sleeping instead of rescheduling for the next time interval. Also I am not sure your SR-IOV creation time test is a good justification for this extra overhead. With your patches applied all you are doing is making use of the free time before the test to do the page zeroing instead of doing it during your test. As such your CPU overhead prior to running the test would be higher and you haven't captured that information. One thing I would be interested in seeing is what is the load this is adding when you are running simple memory allocation/free type tests on the system. For example it might be useful to see what the will-it-scale page_fault1 tests look like with this patch applied versus not applied. I suspect it would be adding some amount of overhead as you have to spend a ton of time scanning all the pages and that will be considerable overhead.