Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1423043pxb; Thu, 4 Mar 2021 10:52:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTg4SHdw17an5KV1eNm0gJUP0bib3HF8+VIuCcRMN3/+kR7xg4KMTAjWphz4Rw9PWngtJp X-Received: by 2002:a17:907:1b1f:: with SMTP id mp31mr5844865ejc.348.1614883937750; Thu, 04 Mar 2021 10:52:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614883937; cv=none; d=google.com; s=arc-20160816; b=kwPlSjOrvbUkYgvisHt/f4+rDaUNeFmDwL5G42nkj+1sqWUW49nVo+2t+JqQoqbHnb HP1zvUaXhcbMtWex6tPSbNUPx0NcI1QgA3TgkwG0n/u0wHaEpIHFJubcX3lQDEWQLW3q eBpx69awZp5gEfDrSxoc3xuA6tNeLAQN7Rso8NMgBfkWNBHog0txw4Zo8lSwZUY5/0rr bE3vV9GT0w+sgHrHKjRWXiISu2g7TwtwfQlNKxAch4mJAAeYpraXKp5QtcK7rViAtZ3F E0/7UgzPKPT0k0k2Rrcfra3ZZZ11vxD+pxs3L9Gl6AHQ03T49a4PeqS0EL9E8wk9EhKF Jdfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject :organization:from:references:cc:to:dkim-signature; bh=+Q+msirUjwPNJ/6VeaFJuWexxOMnxBOOZp0eEWINW9s=; b=vS/mKSdeZz1akP8AgxJgFD2hxXfBCZPpPDEaLU0qopKj/wSHWqOngtyNVzUZhxZ3K4 K5w1FJluekHOZjVdOJ+tLQeEbuBBrjiaElMseJCna2l0cPjV5bo2z4m6vnhevkRbEbqm GpUh9avpvDKaQOsiusSGxg3naUZhRTbEl4yx9CoiKE2oyHS1jFhPoBjW889BPK7w3Y/M u/DZA4Tv8F67bg2ryYe//WExF3oSRnqQrnR4TJPVTvaxLGM0YR8Izwdj/FRcpuSqmGIr awAdQVDDKnaS/Igni3TG0VbEMZ9B3aBHbVBDFbsPXta/gzib3Mq3KvTPUx/n32HrgRcm 2oPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iltkBEt0; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w24si169369eds.559.2021.03.04.10.51.55; Thu, 04 Mar 2021 10:52:17 -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=@redhat.com header.s=mimecast20190719 header.b=iltkBEt0; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239227AbhCDRZJ (ORCPT + 99 others); Thu, 4 Mar 2021 12:25:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56069 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231439AbhCDRYl (ORCPT ); Thu, 4 Mar 2021 12:24:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614878596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Q+msirUjwPNJ/6VeaFJuWexxOMnxBOOZp0eEWINW9s=; b=iltkBEt0UyWXvvkIXmYC03ZijRDhoLA4B0pOf1hxkjVEEBDHR4DSNQQHr+hKayELst5QMP 3eFwXj8Q9XMErQCwaBkqrdwyYAgI/7jb4Het+8jPYVuEA7qW/qtyTpI9g5NTrItFcdh2Ez qmcB2sZ3Zb8znkkfY6h4/JOpcIiqOR8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-597-W1S7B9z3NiaqN7idFXyDmQ-1; Thu, 04 Mar 2021 12:23:14 -0500 X-MC-Unique: W1S7B9z3NiaqN7idFXyDmQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8814057; Thu, 4 Mar 2021 17:23:12 +0000 (UTC) Received: from [10.36.113.171] (ovpn-113-171.ams2.redhat.com [10.36.113.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ADC41002393; Thu, 4 Mar 2021 17:23:10 +0000 (UTC) To: Minchan Kim Cc: Michal Hocko , Andrew Morton , linux-mm , LKML , joaodias@google.com References: <2f167b3c-5f0a-444a-c627-49181fc8fe0d@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Subject: Re: [PATCH] mm: be more verbose for alloc_contig_range faliures Message-ID: Date: Thu, 4 Mar 2021 18:23:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> You want to debug something, so you try triggering it and capturing debug >> data. There are not that many alloc_contig_range() users such that this >> would really be an issue to isolate ... > > cma_alloc uses alloc_contig_range and cma_alloc has lots of users. > Even, it is expoerted by dmabuf so any userspace would trigger the > allocation by their own. Some of them could be tolerant for the failure, > rest of them could be critical. We should't expect it by limited kernel > usecase. Assume you are debugging allocation failures. You either collect the data yourself or ask someone to send you that output. You care about any alloc_contig_range() allocation failures that shouldn't happen, don't you? > >> >> Strictly speaking: any allocation failure on ZONE_MOVABLE or CMA is >> problematic (putting aside NORETRY logic and similar aside). So any such >> page you hit is worth investigating and, therefore, worth getting logged for >> debugging purposes. > > If you believe the every alloc_contig_range failure is problematic Every one where we should have guarantees I guess: ZONE_MOVABLE or MIGRAT_CMA. On ZONE_NORMAL, there are no guarantees. > and there is no such realy example I menionted above in the world, > I am happy to put this chunk to support dynamic debugging. > Okay? > > +#if defined(CONFIG_DYNAMIC_DEBUG) || \ > + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) > +static DEFINE_RATELIMIT_STATE(alloc_contig_ratelimit_state, > + DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); > +int alloc_contig_ratelimit(void) > +{ > + return __ratelimit(&alloc_contig_ratelimit_state); > +} > + ^ do we need ratelimiting with dynamic debugging enabled? > +void dump_migrate_failure_pages(struct list_head *page_list) > +{ > + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, > + "migrate failure"); > + if (DYNAMIC_DEBUG_BRANCH(descriptor) && > + alloc_contig_ratelimit()) { > + struct page *page; > + > + WARN(1, "failed callstack"); > + list_for_each_entry(page, page_list, lru) > + dump_page(page, "migration failure"); Are all pages on the list guaranteed to be problematic, or only the first entry? I assume all. > + } > +} > +#else > +static inline void dump_migrate_failure_pages(struct list_head *page_list) > +{ > +} > +#endif > + > /* [start, end) must belong to a single zone. */ > static int __alloc_contig_migrate_range(struct compact_control *cc, > unsigned long start, unsigned long end) > @@ -8496,6 +8522,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, > NULL, (unsigned long)&mtc, cc->mode, MR_CONTIG_RANGE); > } > if (ret < 0) { > + dump_migrate_failure_pages(&cc->migratepages); > putback_movable_pages(&cc->migratepages); > return ret; > } > > If that's the way dynamic debugging is configured/enabled (still have to look into it) - yes, that goes into the right direction. As I said above, you should dump only where we have some kind of guarantees I assume. -- Thanks, David / dhildenb