Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15798073rwd; Mon, 26 Jun 2023 01:12:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UBlJS0OH6TCnn2MaOt3c0sPj+iKpApI3jJYqGLdij8i5HI+MPM7M+GDjSc6THpW3HAZ3w X-Received: by 2002:a17:907:7628:b0:98e:a54:42e3 with SMTP id jy8-20020a170907762800b0098e0a5442e3mr2475095ejc.54.1687767177265; Mon, 26 Jun 2023 01:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687767177; cv=none; d=google.com; s=arc-20160816; b=gjSRc0ZmyPHglzUu0HwVDVwEYo3HDtQzh+DmjQDAmw7TLxaHRiIi9sNGK0V+oEDqzM tp5srFs8UVHMMRE1zJqVI5d5ngjN18f/It/8V8PzRGfKuHg/lmO1b50a2dT3mreytpoL RdQ8ucw8hox0qxr88WCt2T9XhxBlIoV3C9TAeSYkD7h4HSL3OnJC9GkUPF8aA0n8KZQb s+39+d33r82qji1ii18lZBw4c21McO9TZRpGFfGBiJ7SPbL8MS00B+ymusV8nSZ8Gykb d/vh5CnV2cdmRLwKLTqgy4qRxaPz0BN37enGJUlB8ZQlR7TTf/SxldiIvSDMY8O7VRFw aXlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=IeCgRQNxrQ3a1y0bp9EimGNrftDyKTpDVhxmrEZe8Vo=; fh=nYWgPEfyGZbtxza3MsumVe7u8sO1/GBSejk2haJ6pLg=; b=rLkXNBUr9aAPRErdtjoQVWrDt0X5qgsM1wEZl3DV4idr+h4Dz9+1g9Jpy8Ns3RQ01o dXZFHQaw5oEefR3fllbBPrpi24wgkrXC5MMAQPHU5HN7bAdNP51xlMLsjrxavaQlOb87 xbOmQX8kFuCbsted8N99ocGSc3A4+xr5L38yrFuExw0uFLiLMPAWnxeUUbkVJjle1R1Y oa3ELzFkqg2OOHulA7+hlEaK/cF1RZfsTCw1eqY2wclZIYlo1oi2VUR9YWuzvrpBkILI tmD7yalo5EdrVNnoefqFrZpnMrlxYJiBXONlL0z50pbmsspBA/GaoHQ2/QtoKKc83Pgw OzQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perex.cz header.s=default header.b=fpj8S7Js; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x26-20020a170906b09a00b00988919c8a70si2496131ejy.59.2023.06.26.01.12.31; Mon, 26 Jun 2023 01:12:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@perex.cz header.s=default header.b=fpj8S7Js; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=perex.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbjFZH5D (ORCPT + 99 others); Mon, 26 Jun 2023 03:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbjFZH5B (ORCPT ); Mon, 26 Jun 2023 03:57:01 -0400 Received: from mail1.perex.cz (mail1.perex.cz [77.48.224.245]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F0B110A for ; Mon, 26 Jun 2023 00:56:58 -0700 (PDT) Received: from mail1.perex.cz (localhost [127.0.0.1]) by smtp1.perex.cz (Perex's E-mail Delivery System) with ESMTP id B87A81E24; Mon, 26 Jun 2023 09:56:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.perex.cz B87A81E24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perex.cz; s=default; t=1687766213; bh=IeCgRQNxrQ3a1y0bp9EimGNrftDyKTpDVhxmrEZe8Vo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fpj8S7Js7MWRLdA0pP1JWmLs1UlFE7sg15ctxSBVvR9P3PBqF6uoj2NaScJLWKRum P7lDcTvBWlAIXfL/SurcqZCYeHQ+C45RaGkJb7hF4Z8Yc6VMLaCQIsPP0+kGf/XsRS e9xjePgclLpTi+P5j1FL5LlAn+Sm+Ww6Km2Mzfw0= Received: from [192.168.100.98] (unknown [192.168.100.98]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: perex) by mail1.perex.cz (Perex's E-mail Delivery System) with ESMTPSA; Mon, 26 Jun 2023 09:56:47 +0200 (CEST) Message-ID: <4d0931bf-b356-6969-5aaf-b663d7f2b21a@perex.cz> Date: Mon, 26 Jun 2023 09:56:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [BUG] ALSA: core: pcm_memory: a possible data race in do_alloc_pages() Content-Language: en-US To: Takashi Iwai , Tuo Li Cc: tiwai@suse.com, alsa-devel@alsa-project.org, Linux Kernel , baijiaju1990@outlook.com References: <877crqwvi1.wl-tiwai@suse.de> <871qhywucj.wl-tiwai@suse.de> From: Jaroslav Kysela In-Reply-To: <871qhywucj.wl-tiwai@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26. 06. 23 9:33, Takashi Iwai wrote: > On Mon, 26 Jun 2023 09:31:18 +0200, > Tuo Li wrote: >> >> >> Hello, >> >> Thank you for your reply! > > FWIW, the simplest fix would be something like below, just extending > the mutex coverage. But it'll serialize the all calls, so it might > influence on the performance, while it's the safest way. It may be better to update total_pcm_alloc_bytes before snd_dma_alloc_dir_pages() call and decrease this value when allocation fails to allow parallel allocations. Then the mutex can be held only for the total_pcm_alloc_bytes variable update. Eventually, total_pcm_alloc_bytes may be atomic. Jaroslav -- Jaroslav Kysela Linux Sound Maintainer; ALSA Project; Red Hat, Inc.