From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbcIBKKV (ORCPT ); Fri, 2 Sep 2016 06:10:21 -0400 Received: from mail.dev.rtsoft.ru ([213.79.90.226]:54161 "EHLO mail.dev.rtsoft.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752979AbcIBKKT (ORCPT ); Fri, 2 Sep 2016 06:10:19 -0400 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.dev.rtsoft.ru C30DE41AE3 Subject: Re: alloc_pages_exact() triggering memory fragmentation on nommu? To: "linux-kernel@vger.kernel.org" References: <101164ee-b72e-7792-b081-0cdd94769759@dev.rtsoft.ru> Cc: Alexey Maximov From: Nikita Yushchenko X-Enigmail-Draft-Status: N1110 Organization: RTSoft Software Development Center Message-ID: <252b146d-4a12-edff-2ed6-c6ffbf65527a@dev.rtsoft.ru> Date: Fri, 2 Sep 2016 13:10:15 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <101164ee-b72e-7792-b081-0cdd94769759@dev.rtsoft.ru> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > I'm having a guess that this can be caused by use of > alloc_pages_exact() for NoMMU private anonymous mappings. > > This routine causes "tail" of allocation to be returned back > to allocator... and inserted at top of free list. Later, when > whatever in the system makes a trivial order-0 allocation, these > just-freed tails immediately get used (because free pages are > inserted at end of free lists... and new pages are allocated > from either beginning or end of free list, depending on 'cold' > parameter). At a glance, this should have a net effect of much > increased probability of "tail" of large allocation get used > as a small allocation, and thus inability to rebuild a large free > block at time when large allocation is freed. > > Is there any protection against this effect in the allocator > of current kernels? (kernel of system in question is somewhat > outdated) Just a small followup to whoever may be interested. The guess was correct. In old 3.0.8 kernel running on system in question, do_mmap_private() in mm/nommu.c did not yet use alloc_pages_exact() but instead had it's own implementation of the same logic. And there was a tunable 'nr_trim_pages' that could alter it. In particular setting that tunable to 0 effectively disabled any freeing of tails. We tried to set nr_trim_pages=0 and fragmentation issue went away. Nikita