Received: by 10.223.171.12 with SMTP id q12csp13597wrc; Tue, 6 Feb 2018 15:49:20 -0800 (PST) X-Google-Smtp-Source: AH8x2259sO8XyMW9oD10nfKrffH/bWvLbpYZXyFRz/bNxwxNaamjHtqdkKIUTBS81Ox6os/IxWQh X-Received: by 10.101.96.215 with SMTP id r23mr3241607pgv.139.1517960959922; Tue, 06 Feb 2018 15:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517960959; cv=none; d=google.com; s=arc-20160816; b=xj3uhlqAJpAOvDby6mfwFm8geyqRIIDshmPU4xh58zlgSSfyFDfE1wjcsZBi4d5mHN KgAp8W9K8CAhDaDqRlakU/aRa5j71UgrT6HucIoihQPTtEoirH3AnE2R6SjbVQkYGZdd 0Tq+gj/P8L1YPJiOhkGO8UBHGiI2fR5qQVTz9LIaWIdT8VBwC7VBhtb7MZjd5EqNqHhY k99FTJb/qwwy+SZBXyn2yvaUmtzNAfAawfaAPUdlcoClGRUssaij/AtxmjqO37OcVWBv YtIEurA+dFbD0s7dBccibgoAwjI5chlWJkTI+qesm/w8uFl893GhexKv3JdPR8IkC3sk Gy1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=E7sClONl1nQ8z52HK82ApoFF1hIc2pSjUDS0OBCKi74=; b=QsHK3ITk6VeIKgJKOILwEJFfr1bkUktn8hL0lOMCb5/I7irJIh/FsdaO65QrC61YEK SNBe3/4mbwceiqZbwCNiqizVququMrfO0BGr0jPe6JkTFvEYe2qubn3rOEMaJDANx8/t JpQVu6wb+f5cZONZAXSR0J6f9JkNwI+Z8hmRZAgQrTqQTdgoXZeV+kvlAIa2buHeIsQK b8HSHAakgJSNUtJrsMgXLe7oX3f4ufQR/sMeW6b3047cfsm6LRkrZ/WXllkiV0QSncpO 2CBDfrGaNTi0j4ikynVteJZwpHq/zuZu36QkNuUx5fySuFqTJghOWeVAyw7DHPLJ4QBi lliw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q11si122197pgf.84.2018.02.06.15.49.05; Tue, 06 Feb 2018 15:49:19 -0800 (PST) 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754210AbeBFXsF (ORCPT + 99 others); Tue, 6 Feb 2018 18:48:05 -0500 Received: from mail-oi0-f52.google.com ([209.85.218.52]:42428 "EHLO mail-oi0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753346AbeBFXsE (ORCPT ); Tue, 6 Feb 2018 18:48:04 -0500 Received: by mail-oi0-f52.google.com with SMTP id c8so2694532oiy.9 for ; Tue, 06 Feb 2018 15:48:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=E7sClONl1nQ8z52HK82ApoFF1hIc2pSjUDS0OBCKi74=; b=sY0a41ejI5qF++uHAN5agpwb2HrrpCPBIuzW95p5c3URqbMm5aDQqZ/t+rZUYdjU6B VRYIImRKPwxOPdeh3vyo6l2qDu8Z56LxTaSbEZlPBSGJDWQdwF4o9ylO2rfaNiwz1pOE RkLdIrRkv/Wfx0rPWiNFofnLwwMhsYFJlPk16E0OadQhetSja+GRJEuFHvIWU7vI0F26 2g4+gQ2Udk0b6h/mMBoYZBN4j0o6OeSAy1JvMTp3h4b0ypJ80Uh5CsPKcCHIUiJK9iya kYTOMhqwEhlZYu9bXgLmzmJydgNy/j0PwPjNAjXn0Pea+hgOF5DyyrUormqmOFQetJuP 5ZbA== X-Gm-Message-State: APf1xPCfUNG3tWZgIPUHA87BGNgfMYsiZMcQpAJmX4SZdns+Xa6DIAAQ cb7UddWUYYmOI+3EVNWIX0Qmc4Y0vYg= X-Received: by 10.202.81.15 with SMTP id f15mr2718899oib.332.1517960883263; Tue, 06 Feb 2018 15:48:03 -0800 (PST) Received: from ?IPv6:2601:602:9802:a8dc::f21a? ([2601:602:9802:a8dc::f21a]) by smtp.gmail.com with ESMTPSA id i25sm96740ote.49.2018.02.06.15.48.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 15:48:02 -0800 (PST) Subject: Re: staging: ion: ION allocation fall back order depends on heap linkage order To: Alexey Skidanov , devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org References: From: Laura Abbott Message-ID: <58951af2-a84e-7d7c-e956-ece3190aa8c2@redhat.com> Date: Tue, 6 Feb 2018 15:48:01 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/28/2018 08:24 AM, Alexey Skidanov wrote: > Hi, > > According to my understanding, the allocation fall back order > completely depends on heap->id that is assigned during the heap > creation: > plist_for_each_entry(heap, &dev->heaps, node) { > /* if the caller didn't specify this heap id */ > if (!((1 << heap->id) & heap_id_mask)) > continue; > buffer = ion_buffer_create(heap, dev, len, flags); > if (!IS_ERR(buffer)) > break; > } > > On creation, each heap is added to the priority list according to the > priority assigned: > > ... > static int heap_id; > ... > void ion_device_add_heap(struct ion_heap *heap) > { > ... > heap->id = heap_id++; > ... > } > > > The order of creation is the order of linkage defined in the Makefile. > Thus, by default, we have: > > heap id 2, type ION_HEAP_TYPE_DMA > heap id 1, type ION_HEAP_TYPE_SYSTEM > heap id 0, type ION_HEAP_TYPE_SYSTEM_CONTIG > > Changing the linkage order: > diff --git a/drivers/staging/android/ion/Makefile > b/drivers/staging/android/ion/Makefile > index bb30bf8..e05052c 100644 > --- a/drivers/staging/android/ion/Makefile > +++ b/drivers/staging/android/ion/Makefile > @@ -1,6 +1,6 @@ > # SPDX-License-Identifier: GPL-2.0 > obj-$(CONFIG_ION) += ion.o ion-ioctl.o ion_heap.o > -obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o > obj-$(CONFIG_ION_CARVEOUT_HEAP) += ion_carveout_heap.o > obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o > obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o > +obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o > > I get the following order: > > heap id 2, type ION_HEAP_TYPE_SYSTEM > heap id 1, type ION_HEAP_TYPE_SYSTEM_CONTIG > heap id 0, type ION_HEAP_TYPE_DMA > > So, if the user specifies more than 1 heap in the heap_id_mask during > allocation, the allocation fall back order completely depends on the > order of linkage. Probably, it's better to let the user to define the > fall back order (and NOT to be dependent on the linkage order at all) > ? > Yup, you've hit upon a key problem. Having fallbacks be stable was always a problem and the recommendation these days is to not rely on them. You can specify a heap at a time and fallback manually if you want that behavior. If you have a proposal to make fallbacks work reliably without overly complicating the ABI I'm happy to review it. Thanks, Laura