From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1D79C433F5 for ; Wed, 29 Sep 2021 16:09:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A0A3615E0 for ; Wed, 29 Sep 2021 16:09:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3A0A3615E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6B42A94003E; Wed, 29 Sep 2021 12:09:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6632794003A; Wed, 29 Sep 2021 12:09:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 551E594003E; Wed, 29 Sep 2021 12:09:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 44F7394003A for ; Wed, 29 Sep 2021 12:09:22 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EB9D139B99 for ; Wed, 29 Sep 2021 16:09:21 +0000 (UTC) X-FDA: 78641095722.27.DB8A90C Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by imf27.hostedemail.com (Postfix) with ESMTP id BF78370000BD for ; Wed, 29 Sep 2021 16:09:21 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id dj4so11038658edb.5 for ; Wed, 29 Sep 2021 09:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uaWtDAo3kQSYCQrNbQm2HCi7HuCaEOju1rd0rKAU9dQ=; b=WfDFN+AjqSMPvMlMCOsJcFYl1uex3whdvbM9klc0hcheDieIqdAFIQJhsnsXfizDQt h5uqgLQsafVDIkFEkSDmfSXEcyaIudmJrpA7xh5gbPs+cRKygnx5eW22JA1UjDLiw4fZ H1dMOEu0rF/3q4tBVa29T+wyCKLINjeOFZU020y4uxgIaUrDdYOhWtvH3D8xDG6dvboM GCfdOFaIr+0eK94U/rRJ0pcjpDnKF666XnxzBgMuxgl/YvtDi+IACNfnr0p9frdCw6Dr 9RsSqc346jaQJxeGCddmUzKqZnBtmL4rbk5SDvCf3XRCG1okZvYHQNc2zmG4v0fqRSmQ MHyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uaWtDAo3kQSYCQrNbQm2HCi7HuCaEOju1rd0rKAU9dQ=; b=1GSE7m7OsA/YqY7ZhXVPaFQc91kr5oZMWTScCPt+6reXJ2uZtytrBwejt1TkJy/ui3 t7P8uHPY/BbKVyuMgiyqruLdCXFWWDXHcaf93Oow0qRZrgLianoFlXQ9a0dPwWrsr0Yr vhEMn/AyFtBpunRO/FMTYV5iDy6ewS9ZOXrwQ0sIABLrJgBaDPZLDzwo6cVNLy31ZwBi DYD8TDGLWc6GY/oVU0QIq0ho38AyQNsgNJ+Lvvbq5qpNYI6XC1axM5kZIsCYRLWD+uRk Sr/f7ofLQSiIyELcfiJMSqkZvaSK/ORFP4b6GXyTwimdhFSbLP8QDS3sUA+Udr6IYFN4 qjQg== X-Gm-Message-State: AOAM5317iztNKLkfVRAHFFapgTIE94lRJZfNrzTD7l79yc0vWSI0C/do wohfvKkaLzgDH9aZyTt5koMQt/6A2PYEd/GeiNU= X-Google-Smtp-Source: ABdhPJyrMM22bNMGflNyc+y8rA206GxgP0Bp7Ld+WDu3Hp9kybxMvtdUCZ9+WUrD0DIV6jTyeV3C1mpV667nLwdSIsc= X-Received: by 2002:aa7:c4d0:: with SMTP id p16mr787607edr.71.1632931717974; Wed, 29 Sep 2021 09:08:37 -0700 (PDT) MIME-Version: 1.0 References: <20210908132727.16165-1-david@redhat.com> <20210916193403.GA1940@pc638.lan> <221e38c1-4b8a-8608-455a-6bde544adaf0@redhat.com> <20210921221337.GA60191@pc638.lan> <7f62d710-ca85-7d33-332a-25ff88b5452f@redhat.com> <20210922104141.GA27011@pc638.lan> <953ea84a-aabb-f64b-b417-ba60928430e0@redhat.com> <689b7c24-623d-c01e-6c0f-ad430f1fa3ae@redhat.com> In-Reply-To: <689b7c24-623d-c01e-6c0f-ad430f1fa3ae@redhat.com> From: Uladzislau Rezki Date: Wed, 29 Sep 2021 18:08:26 +0200 Message-ID: Subject: Re: [PATCH v1] mm/vmalloc: fix exact allocations with an alignment > 1 To: David Hildenbrand Cc: LKML , Ping Fang , Andrew Morton , Roman Gushchin , Michal Hocko , Oscar Salvador , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: BF78370000BD X-Stat-Signature: 8waxpdhf8pw4u8joxrzehfrutjr19e9g Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WfDFN+Aj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.50 as permitted sender) smtp.mailfrom=urezki@gmail.com X-HE-Tag: 1632931761-333676 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000187, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > > Could you please to be more specific? I mean how is it connected with huge > > pages mappings? Huge-pages are which have order > 0. Or you mean that > > a special alignments are needed for mapping huge pages? > > Let me try to clarify: > > > KASAN does an exact allocation when onlining a memory block, > __vmalloc_node_range() will try placing huge pages first, increasing the > alignment to e.g., "1 << PMD_SHIFT". > > If we increase the search length in find_vmap_lowest_match(), that > search will fail if the exact allocation is surrounded by other > allocations. In that case, we won't place a huge page although we could > -- because find_vmap_lowest_match() would be imprecise for alignments > > PAGE_SIZE. > > > Memory blocks we online/offline on x86 are at least 128MB. The KASAN > "overhead" we have to allocate is 1/8 of that -- 16 MB, so essentially 8 > huge pages. > > __vmalloc_node_range() will increase the alignment to 2MB to try placing > huge pages first. find_vmap_lowest_match() will search within the given > exact 16MB are a 18MB area (size + align), which won't work. So > __vmalloc_node_range() will fallback to the original PAGE_SIZE alignment > and shift=PAGE_SHIFT. > > __vmalloc_area_node() will set the set_vm_area_page_order effectively to > 0 -- small pages. > > Does that make sense or am I missing something? > Thank you for clarification. OK, we come back anyway to the "problem" with fixed range and an exact allocation plus a special alignment > PAGE_SIZE. Thus the KASAN will not make use of huge pages mappings and go with regular instead as a fallback path. But we would like to utilize huge-mappings for KASAN. I will send the patch you tested and add your "tested-by" tag. Does it sound good? -- Uladzislau Rezki