Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp611775pxb; Sat, 6 Mar 2021 10:19:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwR58I+D0oI4sTjmR/7hiR43FMfvEV3SBPPs4UTHSYomnoS1oxFBa0Pk4DKPz0vaEuTjJsC X-Received: by 2002:a17:906:3b47:: with SMTP id h7mr7734720ejf.377.1615054776633; Sat, 06 Mar 2021 10:19:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615054776; cv=none; d=google.com; s=arc-20160816; b=bWdCC5dn0B0eecSid2CD102RDJa1M77BYLpV3wg8CN6p7AjujW8H37qbokNNGaJr6f sPPRt8YIDl9N5GeLSlsNg9Fw5++s+82klNjVIRX0FfkuuOHKNNyikPDSwwwUIZ5L9dBS zko+oEMXO5g8TFC+JzTBUvjvIt9GnH/4aTLDS+PfFOZwGwOTKYVOsPvHM2dYQVzSi20X opMEnj9IJ7w1QxE5p4hZnxKGqsanKzhCSQdzlEONv7zwV7JPuR46Cjen9Bq7c2nz7GfR 1tttTFYIDLQMnXPhpxBNQj/UiJi45zv7acGrbK+Mv7GmzN0gbm+uEdrGNhE8gjLmDVd9 Hyjw== 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:from:references :cc:to:subject; bh=JjqFOEuF/irQ0wQ7BMz3JdcfoaUBCUP+26117l0UxWo=; b=lOy/Me5OxxGeBbE4qIbzfJ1OjIQ6j3KHtqec6M4B2ETHmdBjQxpD5JE1d5/8rG88bU dCcsjxkFdK5zWdsy9xQClSbY7zPbEOiwyb0av3ImTv+/MG07rmdCfrhBdq1zFsFGOUAD WwYRdsL36QBwho5NUAQHfU4JrZpO6VEKZFHvEho3+tVapKhEC2OTl6LpLxJalrWf/MRF i6akKKWBoF6/YZ1HDewnSvUBUIoW1EGSp9pqI6YpWtYZy1iUup1cdNMJvWKI6NqvZJ4x xfsiKDLcvDD5djKjnrea0GYlG4R2ioqRTMAfZV1Qslj1Ff55bARDLpL4uBX+QOg9RBrc pmRA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd8si3549994ejc.78.2021.03.06.10.19.13; Sat, 06 Mar 2021 10:19:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231236AbhCFSNl (ORCPT + 99 others); Sat, 6 Mar 2021 13:13:41 -0500 Received: from mail-pj1-f50.google.com ([209.85.216.50]:35406 "EHLO mail-pj1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230346AbhCFSNQ (ORCPT ); Sat, 6 Mar 2021 13:13:16 -0500 Received: by mail-pj1-f50.google.com with SMTP id ga23-20020a17090b0397b02900c0b81bbcd4so856742pjb.0; Sat, 06 Mar 2021 10:13:16 -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=JjqFOEuF/irQ0wQ7BMz3JdcfoaUBCUP+26117l0UxWo=; b=EdedKj+kyaRs843I9nODkBSga3MwcdRMamAxpSIMSN35msixygy0u4/32hRqTWI7Lq 6dn3ym71yN6XAiJeaYEx9WklIU/i184IoLROLQa/tKIxhmTRfw78IQxnlL8z+b68uDgC f5eRXaSd25zft5OU7UgV/CsG8e6EUBhbF4lpDQqS9ThoWPrqrbXa0GrnM9UfGZs3+QcC PIjlKuGYWcrdcdpS0k22lEivLvBCLKuefi9SXnJL1SGnnOO/Joo+pT8Bw1IWkt41B+py Zi/wIt65M+d+YFXJ50BqoJA3ywnQvkxVvmScnf7QtdzsP5ZtypVOa88NrGZAN4zJbyxg EUlw== X-Gm-Message-State: AOAM530tvjNVWnyCbtUOoEfzzJqogJyG3k99TMGDO21Nf0eZWaoLQRLh Ad0G0K6/k0W6QR/D/cEl+6MmFPFD6OQ= X-Received: by 2002:a17:90a:20c:: with SMTP id c12mr16287332pjc.224.1615054395496; Sat, 06 Mar 2021 10:13:15 -0800 (PST) Received: from ?IPv6:2601:647:4000:d7:9183:7829:b654:e538? ([2601:647:4000:d7:9183:7829:b654:e538]) by smtp.gmail.com with ESMTPSA id q9sm5646141pgs.28.2021.03.06.10.13.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Mar 2021 10:13:14 -0800 (PST) Subject: Re: [RFC PATCH v3 1/3] blk-mq: Clean up references to old requests when freeing rqs To: John Garry , hare@suse.de, ming.lei@redhat.com, axboe@kernel.dk, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, pragalla@codeaurora.org, kashyap.desai@broadcom.com, yuyufen@huawei.com References: <1614957294-188540-1-git-send-email-john.garry@huawei.com> <1614957294-188540-2-git-send-email-john.garry@huawei.com> From: Bart Van Assche Message-ID: Date: Sat, 6 Mar 2021 10:13:11 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <1614957294-188540-2-git-send-email-john.garry@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/5/21 7:14 AM, John Garry wrote: > @@ -2296,10 +2296,14 @@ void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags, > > for (i = 0; i < tags->nr_tags; i++) { > struct request *rq = tags->static_rqs[i]; > + int j; > > if (!rq) > continue; > set->ops->exit_request(set, rq, hctx_idx); > + /* clean up any references which occur in @ref_tags */ > + for (j = 0; ref_tags && j < ref_tags->nr_tags; j++) > + cmpxchg(&ref_tags->rqs[j], rq, 0); > tags->static_rqs[i] = NULL; > } > } What prevents blk_mq_tagset_busy_iter() from reading hctx->tags[...] before the cmpxcg() call and dereferencing it after blk_mq_free_rqs() has called __free_pages()? Thanks, Bart.